From 6b14a743ccfe5c14e15acac858c0906f4fccdf67 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 15 Dec 2024 12:34:18 +0100 Subject: New state: favorite or unread (#7088) * New state: favorite or unread https://github.com/FreshRSS/FreshRSS/discussions/7078#discussioncomment-11526292 * Experiment using this state by default * Rework state * Allow ANDS for typos * Revert change unrelated to this PR * Revert change of default state * Add option *unread_or_favorite* * Fix hide_read_feeds * i18n: it Co-authored-by: UserRoot-Luca <55756898+UserRoot-Luca@users.noreply.github.com> * Update app/i18n/pl/conf.php Co-authored-by: Zic <55097497+ZicPL@users.noreply.github.com> * Update app/i18n/pl/conf.php Co-authored-by: Zic <55097497+ZicPL@users.noreply.github.com> * Fix i18n * Fix auto_remove_article * Fix mark_unread_enabled --------- Co-authored-by: UserRoot-Luca <55756898+UserRoot-Luca@users.noreply.github.com> Co-authored-by: Zic <55097497+ZicPL@users.noreply.github.com> --- app/Models/Context.php | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'app/Models/Context.php') diff --git a/app/Models/Context.php b/app/Models/Context.php index f39fd0eca..eeb16f414 100644 --- a/app/Models/Context.php +++ b/app/Models/Context.php @@ -224,15 +224,15 @@ final class FreshRSS_Context { self::$state = Minz_Request::paramInt('state') ?: FreshRSS_Context::userConf()->default_state; $state_forced_by_user = Minz_Request::paramString('state') !== ''; - if (!$state_forced_by_user && !self::isStateEnabled(FreshRSS_Entry::STATE_READ)) { - if (FreshRSS_Context::userConf()->default_view === 'all') { - self::$state |= FreshRSS_Entry::STATE_ALL; + if (!$state_forced_by_user) { + if (FreshRSS_Context::userConf()->show_fav_unread && (self::isCurrentGet('s') || self::isCurrentGet('T') || self::isTag())) { + self::$state = FreshRSS_Entry::STATE_NOT_READ | FreshRSS_Entry::STATE_READ; + } elseif (FreshRSS_Context::userConf()->default_view === 'all') { + self::$state = FreshRSS_Entry::STATE_NOT_READ | FreshRSS_Entry::STATE_READ; + } elseif (FreshRSS_Context::userConf()->default_view === 'unread_or_favorite') { + self::$state = FreshRSS_Entry::STATE_OR_NOT_READ | FreshRSS_Entry::STATE_OR_FAVORITE; } elseif (FreshRSS_Context::userConf()->default_view === 'adaptive' && self::$get_unread <= 0) { - self::$state |= FreshRSS_Entry::STATE_READ; - } - if (FreshRSS_Context::userConf()->show_fav_unread && - (self::isCurrentGet('s') || self::isCurrentGet('T') || self::isTag())) { - self::$state |= FreshRSS_Entry::STATE_READ; + self::$state = FreshRSS_Entry::STATE_NOT_READ | FreshRSS_Entry::STATE_READ; } } @@ -553,16 +553,8 @@ final class FreshRSS_Context { * - the "unread" state is enable */ public static function isAutoRemoveAvailable(): bool { - if (!FreshRSS_Context::userConf()->auto_remove_article) { - return false; - } - if (self::isStateEnabled(FreshRSS_Entry::STATE_READ)) { - return false; - } - if (!self::isStateEnabled(FreshRSS_Entry::STATE_NOT_READ)) { - return false; - } - return true; + return FreshRSS_Context::userConf()->auto_remove_article && !self::isStateEnabled(FreshRSS_Entry::STATE_READ) && + (self::isStateEnabled(FreshRSS_Entry::STATE_NOT_READ) || self::isStateEnabled(FreshRSS_Entry::STATE_OR_NOT_READ)); } /** -- cgit v1.2.3