From 348028a29043b7d1d0f80544c44f0454b2c375c3 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 8 Nov 2023 20:23:54 +0100 Subject: New feature important feeds (#5782) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * New feature important feeds * Fix PHPStan * Initial style for important feeds + keep unread * Change UI order * Count important unread * Never mark as read important feeds during scroll * Fix i18n conf.iew.normal regression * Fix reader view * More fix reader view * Create important.svg * Fix title * Fix counter * Account for important during mark-all-as-read * Fix underline colour * 📌 * Changelog --------- Co-authored-by: math-gh <> Co-authored-by: maTh <1645099+math-GH@users.noreply.github.com> --- app/Models/Context.php | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'app/Models/Context.php') diff --git a/app/Models/Context.php b/app/Models/Context.php index c1fa96ae7..9fac52d44 100644 --- a/app/Models/Context.php +++ b/app/Models/Context.php @@ -19,6 +19,7 @@ final class FreshRSS_Context { public static string $name = ''; public static string $description = ''; public static int $total_unread = 0; + public static int $total_important_unread = 0; /** @var array{'all':int,'read':int,'unread':int} */ public static array $total_starred = [ @@ -29,10 +30,11 @@ final class FreshRSS_Context { public static int $get_unread = 0; - /** @var array{'all':bool,'starred':bool,'feed':int|false,'category':int|false,'tag':int|false,'tags':bool} */ + /** @var array{'all':bool,'starred':bool,'important':bool,'feed':int|false,'category':int|false,'tag':int|false,'tags':bool} */ public static array $current_get = [ 'all' => false, 'starred' => false, + 'important' => false, 'feed' => false, 'category' => false, 'tag' => false, @@ -154,9 +156,8 @@ final class FreshRSS_Context { // Update number of read / unread variables. $entryDAO = FreshRSS_Factory::createEntryDao(); self::$total_starred = $entryDAO->countUnreadReadFavorites(); - self::$total_unread = FreshRSS_CategoryDAO::countUnread( - self::$categories, 1 - ); + self::$total_unread = FreshRSS_CategoryDAO::countUnread(self::$categories, FreshRSS_Feed::PRIORITY_MAIN_STREAM); + self::$total_important_unread = FreshRSS_CategoryDAO::countUnread(self::$categories, FreshRSS_Feed::PRIORITY_IMPORTANT); self::_get(Minz_Request::paramString('get') ?: 'a'); @@ -208,12 +209,14 @@ final class FreshRSS_Context { * Return the current get as a string or an array. * * If $array is true, the first item of the returned value is 'f' or 'c' or 't' and the second is the id. - * @phpstan-return ($asArray is true ? array{'a'|'c'|'f'|'s'|'t'|'T',bool|int} : string) + * @phpstan-return ($asArray is true ? array{'a'|'c'|'f'|'i'|'s'|'t'|'T',bool|int} : string) * @return string|array{string,bool|int} */ public static function currentGet(bool $asArray = false) { if (self::$current_get['all']) { return $asArray ? ['a', true] : 'a'; + } elseif (self::$current_get['important']) { + return $asArray ? ['i', true] : 'i'; } elseif (self::$current_get['starred']) { return $asArray ? ['s', true] : 's'; } elseif (self::$current_get['feed']) { @@ -247,6 +250,13 @@ final class FreshRSS_Context { return self::$current_get['all'] != false; } + /** + * @return bool true if the current request targets important feeds, false otherwise. + */ + public static function isImportant(): bool { + return self::$current_get['important'] != false; + } + /** * @return bool true if the current request targets a category, false otherwise. */ @@ -278,6 +288,8 @@ final class FreshRSS_Context { switch($type) { case 'a': return self::$current_get['all']; + case 'i': + return self::$current_get['important']; case 's': return self::$current_get['starred']; case 'f': @@ -325,6 +337,12 @@ final class FreshRSS_Context { self::$description = self::$system_conf->meta_description; self::$get_unread = self::$total_unread; break; + case 'i': + self::$current_get['important'] = true; + self::$name = _t('index.menu.important'); + self::$description = self::$system_conf->meta_description; + self::$get_unread = self::$total_unread; + break; case 's': self::$current_get['starred'] = true; self::$name = _t('index.feed.title_fav'); -- cgit v1.2.3