diff --git a/js/FeedStoreModel.js b/js/FeedStoreModel.js index 736bfbed6..befc441af 100644 --- a/js/FeedStoreModel.js +++ b/js/FeedStoreModel.js @@ -54,45 +54,6 @@ define(["dojo/_base/declare", "dijit/tree/ForestStoreModel"], function (declare) if (treeItem) return this.store.setValue(treeItem, key, value); }, - getNextUnreadFeed: function (feed, is_cat) { - if (!this.store._itemsByIdentity) - return null; - - let treeItem; - - if (is_cat) { - treeItem = this.store._itemsByIdentity['CAT:' + feed]; - } else { - treeItem = this.store._itemsByIdentity['FEED:' + feed]; - } - - const items = this.store._arrayOfAllItems; - - for (let i = 0; i < items.length; i++) { - if (items[i] == treeItem) { - - for (let j = i + 1; j < items.length; j++) { - const unread = this.store.getValue(items[j], 'unread'); - const id = this.store.getValue(items[j], 'id'); - - if (unread > 0 && ((is_cat && id.match("CAT:")) || (!is_cat && id.match("FEED:")))) { - if (!is_cat || !(this.store.hasAttribute(items[j], 'parent_id') && this.store.getValue(items[j], 'parent_id') == feed)) return items[j]; - } - } - - for (let j = 0; j < i; j++) { - const unread = this.store.getValue(items[j], 'unread'); - const id = this.store.getValue(items[j], 'id'); - - if (unread > 0 && ((is_cat && id.match("CAT:")) || (!is_cat && id.match("FEED:")))) { - if (!is_cat || !(this.store.hasAttribute(items[j], 'parent_id') && this.store.getValue(items[j], 'parent_id') == feed)) return items[j]; - } - } - } - } - - return null; - }, hasCats: function () { if (this.store && this.store._itemsByIdentity) return this.store._itemsByIdentity['CAT:-1'] != undefined; diff --git a/js/FeedTree.js b/js/FeedTree.js index 2ad9500fe..4c3c47daf 100755 --- a/js/FeedTree.js +++ b/js/FeedTree.js @@ -381,7 +381,10 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co } }, - getNextFeed: function (feed, is_cat) { + getNextUnread: function(feed, is_cat) { + return this.getNextFeed(feed, is_cat, true); + }, + getNextFeed: function (feed, is_cat, unread_only = false) { let treeItem; if (is_cat) { @@ -399,8 +402,9 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co for (let j = i+1; j < items.length; j++) { const id = String(items[j].id); const box = this._itemNodesMap[id]; + const unread = parseInt(items[j].unread); - if (box) { + if (box && (!unread_only || unread > 0)) { const row = box[0].rowNode; const cat = box[0].rowNode.parentNode.parentNode; diff --git a/js/Feeds.js b/js/Feeds.js index f4eba67dc..f8e64235d 100644 --- a/js/Feeds.js +++ b/js/Feeds.js @@ -584,10 +584,10 @@ const Feeds = { }, getNextUnread: function(feed, is_cat) { const tree = dijit.byId("feedTree"); - const nuf = tree.model.getNextUnreadFeed(feed, is_cat); - if (nuf) - return tree.model.store.getValue(nuf, 'bare_id'); + if (tree) return tree.getNextUnread(feed, is_cat); + + return false; }, search: function() { xhr.json("backend.php",