client/paging: fix endless pager issues

This commit is contained in:
rr- 2016-04-17 09:24:05 +02:00
parent 0bc45e9c45
commit a197368bc5
2 changed files with 7 additions and 1 deletions

View file

@ -22,6 +22,7 @@ class PageController {
}
run(ctx) {
this.pageView.unrender();
this.pageView.render(ctx);
}

View file

@ -17,6 +17,7 @@ class EndlessPageView {
const pagesHolder = source.querySelector('.pages-holder');
views.listenToMessages(target);
views.showView(target, source);
this.active = true;
let headerRendererCtx = ctx;
headerRendererCtx.target = pageHeaderHolder;
@ -90,6 +91,7 @@ class EndlessPageView {
}
unrender() {
this.active = false;
window.removeEventListener('scroll', this.updater, true);
}
@ -104,6 +106,9 @@ class EndlessPageView {
}
ctx.requestPage(pageNumber).then(response => {
if (!this.active) {
return;
}
this.totalPages = Math.ceil(response.total / response.pageSize);
if (response.total) {
const pageNode = this.pageTemplate({
@ -132,7 +137,7 @@ class EndlessPageView {
}
this.fetching = false;
this.updater();
window.setTimeout(() => { this.updater(); }, 10);
if (response.total <= (pageNumber - 1) * response.pageSize) {
events.notify(events.Info, 'No data to show');