link fe: more correct totals updating logic

This commit is contained in:
Fang 2020-02-06 16:52:40 +01:00
parent 50695fe78a
commit e74ec92c4c
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972

View File

@ -127,14 +127,15 @@ export class LinkUpdateReducer {
pages[i] = [];
}
pages[i] = items.concat(pages[i]);
pages.totalItems = pages.totalItems + items.length;
if (pages[i].length <= PAGE_SIZE) {
pages.totalPages = page + 1;
pages.totalItems = (page * PAGE_SIZE) + pages[i].length;
pages.totalPages = Math.ceil(pages.totalItems / PAGE_SIZE);
return pages;
}
// overflow into next page
const tail = pages[i].slice(PAGE_SIZE);
pages[i].length = PAGE_SIZE;
pages.totalItems = pages.totalItems - tail.length;
return this._addNewItems(tail, pages, page+1);
}