From 57604b3851c907534da268ffb9b55f738d6c8e97 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Sat, 8 Jan 2022 14:26:12 +0000 Subject: [PATCH] [PLUGIN][NoteTypeFilter] Always show filtering options --- .../NoteTypeFeedFilter/NoteTypeFeedFilter.php | 58 +++++++++---------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/plugins/NoteTypeFeedFilter/NoteTypeFeedFilter.php b/plugins/NoteTypeFeedFilter/NoteTypeFeedFilter.php index 130b1fd2f5..c718bc72bc 100644 --- a/plugins/NoteTypeFeedFilter/NoteTypeFeedFilter.php +++ b/plugins/NoteTypeFeedFilter/NoteTypeFeedFilter.php @@ -141,37 +141,35 @@ class NoteTypeFeedFilter extends Plugin */ public function onAddFeedActions(Request $request, bool $is_not_empty, &$res): bool { - if ($is_not_empty) { - $qs = []; - parse_str($request->getQueryString(), $qs); - if (\array_key_exists('p', $qs) && \is_string($qs['p'])) { - unset($qs['p']); - } - $types = $this->normalizeTypesList(\is_null($request->get('note-types')) ? [] : explode(',', $request->get('note-types')), add_missing: false); - $ftypes = array_flip($types); - - $tabs = [ - 'all' => [ - 'active' => empty($types) || $types === self::ALLOWED_TYPES, - 'url' => '?' . http_build_query(['note-types' => implode(',', self::ALLOWED_TYPES)], '', '&', \PHP_QUERY_RFC3986), - 'icon' => 'All', - ], - ]; - - foreach (self::ALLOWED_TYPES as $allowed_type) { - $active = \array_key_exists($allowed_type, $ftypes); - $new_types = $this->normalizeTypesList([($active ? '!' : '') . $allowed_type, ...$types], add_missing: false); - $new_qs = $qs; - $new_qs['note-types'] = implode(',', $new_types); - $tabs[$allowed_type] = [ - 'active' => $active, - 'url' => '?' . http_build_query($new_qs, '', '&', \PHP_QUERY_RFC3986), - 'icon' => $allowed_type, - ]; - } - - $res[] = Formatting::twigRenderFile('NoteTypeFeedFilter/tabs.html.twig', ['tabs' => $tabs]); + $qs = []; + parse_str($request->getQueryString(), $qs); + if (\array_key_exists('p', $qs) && \is_string($qs['p'])) { + unset($qs['p']); } + $types = $this->normalizeTypesList(\is_null($request->get('note-types')) ? [] : explode(',', $request->get('note-types')), add_missing: false); + $ftypes = array_flip($types); + + $tabs = [ + 'all' => [ + 'active' => empty($types) || $types === self::ALLOWED_TYPES, + 'url' => '?' . http_build_query(['note-types' => implode(',', self::ALLOWED_TYPES)], '', '&', \PHP_QUERY_RFC3986), + 'icon' => 'All', + ], + ]; + + foreach (self::ALLOWED_TYPES as $allowed_type) { + $active = \array_key_exists($allowed_type, $ftypes); + $new_types = $this->normalizeTypesList([($active ? '!' : '') . $allowed_type, ...$types], add_missing: false); + $new_qs = $qs; + $new_qs['note-types'] = implode(',', $new_types); + $tabs[$allowed_type] = [ + 'active' => $active, + 'url' => '?' . http_build_query($new_qs, '', '&', \PHP_QUERY_RFC3986), + 'icon' => $allowed_type, + ]; + } + + $res[] = Formatting::twigRenderFile('NoteTypeFeedFilter/tabs.html.twig', ['tabs' => $tabs]); return Event::next; }