unify return values for getPreviousFeed and usages of both prev/next

This commit is contained in:
Andrew Dolgov 2021-03-22 07:50:56 +03:00
parent 2e6d48ead7
commit d275134f26
3 changed files with 21 additions and 8 deletions

View File

@ -938,16 +938,16 @@ const App = {
} else {
this.hotkey_actions["next_feed"] = () => {
const rv = dijit.byId("feedTree").getNextFeed(
const [feed, is_cat] = Feeds.getNextFeed(
Feeds.getActive(), Feeds.activeIsCat());
if (rv) Feeds.open({feed: rv[0], is_cat: rv[1], delayed: true})
Feeds.open({feed: feed, is_cat: is_cat, delayed: true})
};
this.hotkey_actions["prev_feed"] = () => {
const rv = dijit.byId("feedTree").getPreviousFeed(
const [feed, is_cat] = Feeds.getPreviousFeed(
Feeds.getActive(), Feeds.activeIsCat());
if (rv) Feeds.open({feed: rv[0], is_cat: rv[1], delayed: true})
Feeds.open({feed: feed, is_cat: is_cat, delayed: true})
};
this.hotkey_actions["next_article_or_scroll"] = (event) => {
if (this.isCombinedMode())

View File

@ -435,7 +435,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co
}
const items = this.model.store._arrayOfAllItems;
let item = items[0] == treeItem ? items[items.length-1] : items[0];
let item = false;
for (let i = 0; i < items.length; i++) {
if (items[i] == treeItem) {
@ -453,7 +453,6 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co
break;
}
}
}
break;
}
@ -463,7 +462,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co
return [this.model.store.getValue(item, 'bare_id'),
!this.model.store.getValue(item, 'id').match('FEED:')];
} else {
return false;
return [false, false];
}
},

View File

@ -583,12 +583,26 @@ const Feeds = {
return false;
},
getNextFeed: function(feed, is_cat) {
const tree = dijit.byId("feedTree");
if (tree) return tree.getNextFeed(feed, is_cat, false);
return [false, false];
},
getPreviousFeed: function(feed, is_cat) {
const tree = dijit.byId("feedTree");
if (tree) return tree.getPreviousFeed(feed, is_cat);
return [false, false];
},
getNextUnread: function(feed, is_cat) {
const tree = dijit.byId("feedTree");
if (tree) return tree.getNextUnread(feed, is_cat);
return false;
return [false, false];
},
search: function() {
xhr.json("backend.php",