From 8808fb4545d467f62fc82886d9f86bc63c8cf962 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 29 Jan 2022 14:19:16 +0100 Subject: Fix keep state after favourites tags (#4178) * Fix keep state after favourites tags #fix https://github.com/FreshRSS/FreshRSS/issues/4124 regression * Optimisation --- app/Controllers/indexController.php | 13 ++++++++----- app/Models/Context.php | 15 +++++++++++---- app/layout/aside_feed.phtml | 20 +++++++++----------- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index d9a59c5e3..8ec5bdb27 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -196,11 +196,14 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController { 'state', FreshRSS_Context::$user_conf->default_state ); $state_forced_by_user = Minz_Request::param('state', false) !== false; - if (FreshRSS_Context::$user_conf->default_view === 'adaptive' && - FreshRSS_Context::$get_unread <= 0 && - !FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_READ) && - !$state_forced_by_user) { - FreshRSS_Context::$state |= FreshRSS_Entry::STATE_READ; + if (!$state_forced_by_user && !FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_READ)) { + if (FreshRSS_Context::$user_conf->default_view === 'adaptive' && FreshRSS_Context::$get_unread <= 0) { + FreshRSS_Context::$state |= FreshRSS_Entry::STATE_READ; + } + if (FreshRSS_Context::$user_conf->show_fav_unread && + (FreshRSS_Context::isCurrentGet('s') || FreshRSS_Context::isCurrentGet('T') || FreshRSS_Context::isTag())) { + FreshRSS_Context::$state |= FreshRSS_Entry::STATE_READ; + } } FreshRSS_Context::$search = new FreshRSS_BooleanSearch(Minz_Request::param('search', '')); diff --git a/app/Models/Context.php b/app/Models/Context.php index 62dc53774..ce24c8e4c 100644 --- a/app/Models/Context.php +++ b/app/Models/Context.php @@ -195,16 +195,23 @@ class FreshRSS_Context { } /** - * Return true if the current request targets a feed (and not a category or all articles), false otherwise. + * @return bool true if the current request targets a feed (and not a category or all articles), false otherwise. */ - public static function isFeed() { + public static function isFeed(): bool { return self::$current_get['feed'] != false; } /** - * Return true if $get parameter correspond to the $current_get attribute. + * @return bool true if the current request targets a tag (though not all tags), false otherwise. */ - public static function isCurrentGet($get) { + public static function isTag(): bool { + return self::$current_get['tag'] != false; + } + + /** + * @return bool true if $get parameter correspond to the $current_get attribute. + */ + public static function isCurrentGet($get): bool { $type = $get[0]; $id = substr($get, 2); diff --git a/app/layout/aside_feed.phtml b/app/layout/aside_feed.phtml index 5e6aafe07..0b1680ffb 100644 --- a/app/layout/aside_feed.phtml +++ b/app/layout/aside_feed.phtml @@ -8,11 +8,9 @@ $class = ' state_unread'; } - $state_filter_fav = FreshRSS_Context::$user_conf->show_fav_unread ? '&state=3' : ''; - - $state_filter_cat = Minz_Request::param('state', ''); - if ($state_filter_cat) { - $state_filter_cat = '&state=' . $state_filter_cat; + $state_filter_manual = Minz_Request::param('state', ''); + if ($state_filter_manual != '') { + $state_filter_manual = '&state=' . $state_filter_manual; } ?>