[EVENT][AddFeedActions] Add bool param which denotes whether the feed is empty. [PLUGIN][NoteTypeFeedFilter] Don't show filters if the feed is empty

This commit is contained in:
Hugo Sales 2022-01-02 21:44:08 +00:00 committed by Diogo Peralta Cordeiro
parent d5a6fa924b
commit 8fa04bb47d
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
2 changed files with 30 additions and 28 deletions

View File

@ -14,7 +14,7 @@
<h1>{{ page_title | trans }}</h1>
{% endif %}
<nav class="feed-actions">
{% for block in handle_event('AddFeedActions', app.request) %}
{% for block in handle_event('AddFeedActions', app.request, notes is defined and notes is not empty) %}
{{ block | raw }}
{% endfor %}
</nav>

View File

@ -124,8 +124,9 @@ class NoteTypeFeedFilter extends Plugin
/**
* Draw the media feed navigation.
*/
public function onAddFeedActions(Request $request, &$res): bool
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'])) {
@ -155,6 +156,7 @@ class NoteTypeFeedFilter extends Plugin
}
$res[] = Formatting::twigRenderFile('NoteTypeFeedFilter/tabs.html.twig', ['tabs' => $tabs]);
}
return Event::next;
}