diff --git a/classes/rpc.php b/classes/rpc.php index 94b29ec44..23a45d951 100755 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -564,7 +564,9 @@ class RPC extends Handler_Protected { $hotkeys = array( __("Navigation") => array( "next_feed" => __("Open next feed"), + "next_unread_feed" => __("Open next unread feed"), "prev_feed" => __("Open previous feed"), + "prev_unread_feed" => __("Open previous unread feed"), "next_article_or_scroll" => __("Open next article (in combined mode, scroll down)"), "prev_article_or_scroll" => __("Open previous article (in combined mode, scroll up)"), "next_headlines_page" => __("Scroll headlines by one page down"), @@ -643,7 +645,9 @@ class RPC extends Handler_Protected { static function get_hotkeys_map() { $hotkeys = array( "k" => "next_feed", + "K" => "next_unread_feed", "j" => "prev_feed", + "J" => "prev_unread_feed", "n" => "next_article_noscroll", "p" => "prev_article_noscroll", "N" => "article_page_down", diff --git a/js/App.js b/js/App.js index ecf8c46c1..0afcb0b77 100644 --- a/js/App.js +++ b/js/App.js @@ -944,6 +944,13 @@ const App = { if (feed !== false) Feeds.open({feed: feed, is_cat: is_cat, delayed: true}) }; + this.hotkey_actions["next_unread_feed"] = () => { + const [feed, is_cat] = Feeds.getNextFeed( + Feeds.getActive(), Feeds.activeIsCat(), true); + + if (feed !== false) + Feeds.open({feed: feed, is_cat: is_cat, delayed: true}) + }; this.hotkey_actions["prev_feed"] = () => { const [feed, is_cat] = Feeds.getPreviousFeed( Feeds.getActive(), Feeds.activeIsCat()); @@ -951,6 +958,13 @@ const App = { if (feed !== false) Feeds.open({feed: feed, is_cat: is_cat, delayed: true}) }; + this.hotkey_actions["prev_unread_feed"] = () => { + const [feed, is_cat] = Feeds.getPreviousFeed( + Feeds.getActive(), Feeds.activeIsCat(), true); + + if (feed !== false) + Feeds.open({feed: feed, is_cat: is_cat, delayed: true}) + }; this.hotkey_actions["next_article_or_scroll"] = (event) => { if (this.isCombinedMode()) Headlines.scroll(Headlines.line_scroll_offset, event); diff --git a/js/FeedTree.js b/js/FeedTree.js index b81638c39..e0c44e2b5 100755 --- a/js/FeedTree.js +++ b/js/FeedTree.js @@ -434,14 +434,15 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co return [false, false]; }, - _prevTreeItemFromIndex: function (start) { + _prevTreeItemFromIndex: function (start, unread_only) { const items = this.model.store._arrayOfAllItems; for (let i = start-1; i > 0; i--) { const id = String(items[i].id); const box = this._itemNodesMap[id]; + const unread = parseInt(items[i].unread); - if (box) { + if (box && (!unread_only || unread > 0)) { const row = box[0].rowNode; const cat = box[0].rowNode.parentNode.parentNode; @@ -451,7 +452,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co } } }, - getPreviousFeed: function (feed, is_cat) { + getPreviousFeed: function (feed, is_cat, unread_only = false) { let treeItem; if (is_cat) { @@ -464,11 +465,11 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co const start = items.indexOf(treeItem); if (start != -1) { - let item = this._prevTreeItemFromIndex(start); + let item = this._prevTreeItemFromIndex(start, unread_only); // wrap from the bottom if (!item) { - item = this._prevTreeItemFromIndex(items.length); + item = this._prevTreeItemFromIndex(items.length, unread_only); } if (item) diff --git a/js/Feeds.js b/js/Feeds.js index befd7e46e..27586ab13 100644 --- a/js/Feeds.js +++ b/js/Feeds.js @@ -583,17 +583,17 @@ const Feeds = { return false; }, - getNextFeed: function(feed, is_cat) { + getNextFeed: function(feed, is_cat, unread_only = false) { const tree = dijit.byId("feedTree"); - if (tree) return tree.getNextFeed(feed, is_cat, false); + if (tree) return tree.getNextFeed(feed, is_cat, unread_only); return [false, false]; }, - getPreviousFeed: function(feed, is_cat) { + getPreviousFeed: function(feed, is_cat, unread_only = false) { const tree = dijit.byId("feedTree"); - if (tree) return tree.getPreviousFeed(feed, is_cat); + if (tree) return tree.getPreviousFeed(feed, is_cat, unread_only); return [false, false]; }, diff --git a/plugins/hotkeys_swap_jk/init.php b/plugins/hotkeys_swap_jk/init.php index 19a3ab60a..ff45a65e4 100644 --- a/plugins/hotkeys_swap_jk/init.php +++ b/plugins/hotkeys_swap_jk/init.php @@ -18,7 +18,9 @@ class Hotkeys_Swap_JK extends Plugin { function hook_hotkey_map($hotkeys) { $hotkeys["j"] = "next_feed"; + $hotkeys["J"] = "next_unread_feed"; $hotkeys["k"] = "prev_feed"; + $hotkeys["K"] = "prev_unread_feed"; return $hotkeys; }