Make sure pages loading count is kept in sync

This commit is contained in:
Toby Zerner 2015-07-27 12:16:05 +09:30
parent 0691e493a5
commit 0a2282f4ba

View File

@ -301,7 +301,11 @@ class PostStream extends mixin(Component, evented) {
const twoPagesAway = start - this.constructor.loadCount * 2; const twoPagesAway = start - this.constructor.loadCount * 2;
if (twoPagesAway > this.visibleStart && twoPagesAway >= 0) { if (twoPagesAway > this.visibleStart && twoPagesAway >= 0) {
this.visibleStart = twoPagesAway + this.constructor.loadCount + 1; this.visibleStart = twoPagesAway + this.constructor.loadCount + 1;
clearTimeout(this.loadPageTimeouts[twoPagesAway]);
if (this.loadPageTimeouts[twoPagesAway]) {
clearTimeout(this.loadPageTimeouts[twoPagesAway]);
this.pagesLoading--;
}
} }
this.loadPage(start, end); this.loadPage(start, end);
@ -319,7 +323,11 @@ class PostStream extends mixin(Component, evented) {
const twoPagesAway = start + this.constructor.loadCount * 2; const twoPagesAway = start + this.constructor.loadCount * 2;
if (twoPagesAway < this.visibleEnd && twoPagesAway <= this.count()) { if (twoPagesAway < this.visibleEnd && twoPagesAway <= this.count()) {
this.visibleEnd = twoPagesAway; this.visibleEnd = twoPagesAway;
clearTimeout(this.loadPageTimeouts[twoPagesAway]);
if (this.loadPageTimeouts[twoPagesAway]) {
clearTimeout(this.loadPageTimeouts[twoPagesAway]);
this.pagesLoading--;
}
} }
this.loadPage(start, end, true); this.loadPage(start, end, true);