diff options
| author | 2019-12-04 08:29:20 +0100 | |
|---|---|---|
| committer | 2019-12-04 08:29:20 +0100 | |
| commit | 1ce94136e0886fd26f3ed0f93849cd8fdb4cb2f4 (patch) | |
| tree | 0c9d83b4c27ede8e49db2b042adaf88bacac499a | |
| parent | 3e49b44839237693ce1a8151325942704917f6c6 (diff) | |
Update navigation on empty feeds (#2687)
When using feed navigation, the previous behavior was to cycle through all
available feeds regardless of their content. To match the behaviour of the
first feed and last feed navigation shortcuts, the navigation now skips
empty feeds. Now it's consistent through out the application.
When using feed navigation with only empty feeds, the new behavior is to
cycle through all available feeds.
See #2385
| -rw-r--r-- | p/scripts/main.js | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/p/scripts/main.js b/p/scripts/main.js index 361bed02a..9ebc4c247 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -461,34 +461,58 @@ function next_entry(skipping) { function prev_feed() { let found = false; + let adjacent = null; const feeds = document.querySelectorAll('#aside_feed .feed'); for (let i = feeds.length - 1; i >= 0; i--) { const feed = feeds[i]; - if (found && getComputedStyle(feed).display !== 'none') { - delayedClick(feed.querySelector('a.item-title')); - break; - } else if (feed.classList.contains('active')) { + if (feed.classList.contains('active')) { found = true; + continue; + } + if (!found) { + continue; + } + if (getComputedStyle(feed).display === 'none') { + continue; + } + if (feed.dataset.unread != 0) { + return delayedClick(feed.querySelector('a.item-title')); + } else if (adjacent === null) { + adjacent = feed; } } - if (!found) { + if (found) { + delayedClick(adjacent.querySelector('a.item-title')); + } else { last_feed(); } } function next_feed() { let found = false; + let adjacent = null; const feeds = document.querySelectorAll('#aside_feed .feed'); for (let i = 0; i < feeds.length; i++) { const feed = feeds[i]; - if (found && getComputedStyle(feed).display !== 'none') { - delayedClick(feed.querySelector('a.item-title')); - break; - } else if (feed.classList.contains('active')) { + if (feed.classList.contains('active')) { found = true; + continue; + } + if (!found) { + continue; + } + if (getComputedStyle(feed).display === 'none') { + continue; + } + if (feed.dataset.unread != 0) { + return delayedClick(feed.querySelector('a.item-title')); + } else if (adjacent === null) { + adjacent = feed; } } - if (!found) { + if (found) { + delayedClick(adjacent.querySelector('a.item-title')); + } else { first_feed(); } } |
