aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers/entryController.php
diff options
context:
space:
mode:
authorGravatar Mike <mtalexan@users.noreply.github.com> 2024-10-17 08:38:25 +0000
committerGravatar GitHub <noreply@github.com> 2024-10-17 10:38:25 +0200
commit24a4fcb5c3a001ee9810d7140f107160472fc1d5 (patch)
treead41446c937a6b1b3768bd466129100dad333378 /app/Controllers/entryController.php
parentd9a82e6b9e92276122c75843183d3e42f3e17559 (diff)
Add move to next unread Label on mark as read. (#6886)
* Add move to next unread Label on mark as read. The Labels, unlike the Feeds and Categories, don't move to the next unread when "move to next unread on mark all as read" user feature is enabled. Labels are more complex than Feeds and Categories because Entries can be in more than Label at a time. So when marking all Entries in the Label as read, it can cause other Labels to end up with all their Entries marked as read as well. The calculation of what the next Label/Feed/Category is to jump to normally happens when generating the link for the "Mark as Read" buttons, but it can't for Labels. To address the problem for Labels, use a placeholder value during the pre-calculation of the "Mark as Read" button link. When that placeholder value is encountered during the "Mark as Read" action, the next Label with unread Entries will be calculated immediately after the mark as read action has been processed. Fix all the translations of the 'jump_next' text to remove the '(feed or categories' part that no longer applies. Attempt to fix the inconsistent Russian, Italian, and Polish translations of 'jump_next' text, which phrased the '(feed or categories)' part differently. * Minor code formattting * Fixes * Optimize next label lookup. Only get the tag list once, and actually error check that it returned successfully. Fix a typo in a comment as well. * Fix fallback when all Labels are read. Fix the missing check for whether we're in the fallback case or not. * Update app/i18n/ru/conf.php * Update app/Controllers/entryController.php * Minor changes * One more minor --------- Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Diffstat (limited to 'app/Controllers/entryController.php')
-rw-r--r--app/Controllers/entryController.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/app/Controllers/entryController.php b/app/Controllers/entryController.php
index 4f8fa3452..2cbd256bc 100644
--- a/app/Controllers/entryController.php
+++ b/app/Controllers/entryController.php
@@ -102,6 +102,45 @@ class FreshRSS_entry_Controller extends FreshRSS_ActionController {
break;
case 't':
$entryDAO->markReadTag($get, $id_max, FreshRSS_Context::$search, FreshRSS_Context::$state, $is_read);
+ // Marking all entries in a tag as read can result in other tags also having all entries marked as read,
+ // so the next unread tag calculation is deferred by passing next_get = 'a' instead of the current get ID.
+ if ($next_get === 'a' && $is_read) {
+ $tagDAO = FreshRSS_Factory::createTagDao();
+ $tagsList = $tagDAO->listTags() ?: [];
+ $found_tag = false;
+ foreach ($tagsList as $tag) {
+ if ($found_tag) {
+ // Found the tag matching our current ID already, so now we're just looking for the first unread
+ if ($tag->nbUnread() > 0) {
+ $next_get = 't_' . $tag->id();
+ break;
+ }
+ } else {
+ // Still looking for the tag ID matching our $get that was just marked as read
+ if ($tag->id() === $get) {
+ $found_tag = true;
+ }
+ }
+ }
+ // Didn't find any unread tags after the current one? Start over from the beginning.
+ if ($next_get === 'a') {
+ foreach ($tagsList as $tag) {
+ // Check this first so we can return to the current tag if it's the only one that's unread
+ if ($tag->nbUnread() > 0) {
+ $next_get = 't_' . $tag->id();
+ break;
+ }
+ // Give up if reached our first tag again
+ if ($tag->id() === $get) {
+ break;
+ }
+ }
+ }
+ // If we still haven't found any unread tags, fallback to the full tag list
+ if ($next_get === 'a') {
+ $next_get = 'T';
+ }
+ }
break;
case 'T':
$entryDAO->markReadTag(0, $id_max, FreshRSS_Context::$search, FreshRSS_Context::$state, $is_read);