Browse Source

fix: reset page if skipCount does not change

pull/6605/head
Arman Ozak 6 years ago
parent
commit
38b5c4dda5
  1. 11
      npm/ng-packs/packages/core/src/lib/services/list.service.ts

11
npm/ng-packs/packages/core/src/lib/services/list.service.ts

@ -35,6 +35,7 @@ export class ListService<QueryParamsType = ABP.PageQueryParams> implements OnDes
return this._maxResultCount; return this._maxResultCount;
} }
private _skipCount = 0;
private _page = 0; private _page = 0;
set page(value: number) { set page(value: number) {
if (value === this._page) return; if (value === this._page) return;
@ -81,6 +82,7 @@ export class ListService<QueryParamsType = ABP.PageQueryParams> implements OnDes
} }
get = () => { get = () => {
this.resetPageWhenUnchanged();
this._query$.next(({ this._query$.next(({
filter: this._filter || undefined, filter: this._filter || undefined,
maxResultCount: this._maxResultCount, maxResultCount: this._maxResultCount,
@ -110,6 +112,15 @@ export class ListService<QueryParamsType = ABP.PageQueryParams> implements OnDes
ngOnDestroy() { ngOnDestroy() {
this.destroy$.next(); 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<T, QueryParamsType = ABP.PageQueryParams> = ( export type QueryStreamCreatorCallback<T, QueryParamsType = ABP.PageQueryParams> = (

Loading…
Cancel
Save