Skip to content

Commit

Permalink
Create PaginatedListState#getAllItems and #hasItems methods
Browse files Browse the repository at this point in the history
  • Loading branch information
dsevillamartin committed Apr 25, 2021
1 parent 7b0badf commit c7d129b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion js/src/common/states/PaginatedListState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,22 @@ export default abstract class PaginatedListState<T extends Model> {
return app.store.find(this.type, params);
}

public hasItems(): boolean {
return !!this.getAllItems().length;
}

public isEmpty(): boolean {
return !this.isInitialLoading() && !this.pages.length;
return !this.isInitialLoading() && !this.hasItems();
}

public getLocation(): PaginationLocation {
return this.location;
}

protected getAllItems(): T[] {
return this.pages.map((pg) => pg.items).flat();
}

public isInitialLoading(): boolean {
return this.initialLoading;
}
Expand Down

0 comments on commit c7d129b

Please sign in to comment.