From 38b5c4dda54801f06097860b3d850c7dbb88abc5 Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Fri, 11 Dec 2020 17:04:52 +0300 Subject: [PATCH] fix: reset page if skipCount does not change --- .../packages/core/src/lib/services/list.service.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/npm/ng-packs/packages/core/src/lib/services/list.service.ts b/npm/ng-packs/packages/core/src/lib/services/list.service.ts index 1a1e7c1aeb..375e1c7bcf 100644 --- a/npm/ng-packs/packages/core/src/lib/services/list.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/list.service.ts @@ -35,6 +35,7 @@ export class ListService implements OnDes return this._maxResultCount; } + private _skipCount = 0; private _page = 0; set page(value: number) { if (value === this._page) return; @@ -81,6 +82,7 @@ export class ListService implements OnDes } get = () => { + this.resetPageWhenUnchanged(); this._query$.next(({ filter: this._filter || undefined, maxResultCount: this._maxResultCount, @@ -110,6 +112,15 @@ export class ListService implements OnDes ngOnDestroy() { this.destroy$.next(); } + + private resetPageWhenUnchanged() { + const skipCount = this._page * this._maxResultCount; + + if (skipCount === this._skipCount) { + this._page = 0; + this._skipCount = 0; + } else this._skipCount = skipCount; + } } export type QueryStreamCreatorCallback = (