Have next/prev honor grouped display of articles under feeds.

This commit is contained in:
Andy Valencia 2017-02-10 11:34:14 -08:00
parent d3f2337fd7
commit cc41a55cce

View file

@ -129,6 +129,7 @@ App.prototype.after_login = function(backend) {
App.prototype.logout = function() { App.prototype.logout = function() {
this.backend.logOut(); this.backend.logOut();
this.unread_articles = []; this.unread_articles = [];
this.next_articles = [];
this.populateList(); this.populateList();
this.login.log_out(); this.login.log_out();
}; };
@ -168,6 +169,7 @@ App.prototype.setColor = function(color) {
App.prototype.reload = function() { App.prototype.reload = function() {
this.unread_articles = []; this.unread_articles = [];
this.next_articles = [];
$("#all-read").addClass('inactive'); $("#all-read").addClass('inactive');
var number=parseInt(localStorage.numArticles); var number=parseInt(localStorage.numArticles);
this.backend.reload(this.gotUnreadFeeds.bind(this),number); this.backend.reload(this.gotUnreadFeeds.bind(this),number);
@ -262,6 +264,7 @@ App.prototype.populateList = function() {
// Now build the article list; it's a <ul> of feeds, // Now build the article list; it's a <ul> of feeds,
// then sub-<ul> of articles in that feed // then sub-<ul> of articles in that feed
let html_str = ""; let html_str = "";
this.next_articles = [];
for (let x = 0; x < feeds.length; ++x) { for (let x = 0; x < feeds.length; ++x) {
const xs = x.toString(); const xs = x.toString();
const f = feeds[x]; const f = feeds[x];
@ -272,6 +275,7 @@ App.prototype.populateList = function() {
const feedid = '"feed' + xs + '"'; const feedid = '"feed' + xs + '"';
html_str += '<ul id=' + feedid + ' style="display: none;">' html_str += '<ul id=' + feedid + ' style="display: none;">'
for (let artidx of byfeed[f.fid]) { for (let artidx of byfeed[f.fid]) {
this.next_articles.push(artidx);
const article = ua[artidx]; const article = ua[artidx];
html_str += '<li' + html_str += '<li' +
' id="art' + artidx.toString() + '"' + ' id="art' + artidx.toString() + '"' +
@ -418,25 +422,38 @@ App.prototype.showFull = function(article, slide_back) {
}; };
App.prototype.showNext = function() { App.prototype.showNext = function() {
this.setCurrentRead(); this.setCurrentRead();
if(this.currentIndex >= this.unread_articles.length - 1) { const na = this.next_articles;
this.goToList(); let curidx = na.indexOf(this.currentIndex);
} else {
this.currentIndex++; // Huh, not listed?
this.showFull(this.unread_articles[this.currentIndex], false); if (curidx < 0) {
} this.goToList();
return;
}
curidx += 1;
if (curidx >= na.length) {
this.goToList();
} else {
this.currentIndex = na[curidx];
this.showFull(this.unread_articles[this.currentIndex], false);
}
}; };
App.prototype.showPrevious = function() { App.prototype.showPrevious = function() {
this.setCurrentRead(); this.setCurrentRead();
if(this.currentIndex <= 0) { const na = this.next_articles;
this.goToList(); const curidx = na.indexOf(this.currentIndex)-1;
} else { if (curidx < 0) {
this.currentIndex--; // This handles not found, and also no previous article
this.showFull(this.unread_articles[this.currentIndex], true); this.goToList();
} return;
}
this.currentIndex = na[curidx];
this.showFull(this.unread_articles[this.currentIndex], true);
}; };
App.prototype.setCurrentRead = function() { App.prototype.setCurrentRead = function() {