From 7857e5b79c4509f62b396fb9d526c65c3d4c563e Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Wed, 17 Nov 2021 12:32:07 +0100 Subject: [PATCH] MOBILE-3926 core: Support non-paginated sources --- .../items-management/items-manager-source.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/core/classes/items-management/items-manager-source.ts b/src/core/classes/items-management/items-manager-source.ts index 141cc6f4c..0a4ae17a2 100644 --- a/src/core/classes/items-management/items-manager-source.ts +++ b/src/core/classes/items-management/items-manager-source.ts @@ -76,7 +76,12 @@ export abstract class CoreItemsManagerSource { 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 { /** * 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.