MOBILE-3926 core: Support non-paginated sources

main
Noel De Martin 2021-11-17 12:32:07 +01:00
parent d6d5429ee1
commit 7857e5b79c
1 changed files with 10 additions and 3 deletions

View File

@ -76,7 +76,12 @@ export abstract class CoreItemsManagerSource<Item = unknown> {
return 0;
}
return Math.ceil(this.items.length / this.getPageLength());
const pageLength = this.getPageLength();
if (pageLength === null) {
return 1;
}
return Math.ceil(this.items.length / pageLength);
}
/**
@ -149,9 +154,11 @@ export abstract class CoreItemsManagerSource<Item = unknown> {
/**
* Get the length of each page in the collection.
*
* @return Page length.
* @return Page length; null for collections that don't support pagination.
*/
protected abstract getPageLength(): number;
protected getPageLength(): number | null {
return null;
}
/**
* Update the collection items.