refactor(books): frontend book query service and pagination basics (#2094)

This commit is contained in:
Alex
2026-07-27 09:52:47 +01:00
committed by GitHub
parent 2e4f85c331
commit 111670ef49
15 changed files with 1710 additions and 0 deletions
@@ -0,0 +1,21 @@
import {InfiniteData} from '@tanstack/angular-query-experimental';
import {BrowseFacetGroup, BrowsePage} from '../../../core/data/browse.models';
import {BookSummary} from './book-response.models';
export type BookPage = BrowsePage<BookSummary>;
export type BookFacetGroup = BrowseFacetGroup;
export function flattenBookPages(
data: InfiniteData<BookPage> | undefined,
): BookSummary[] {
const books = data?.pages.flatMap(page => page.content) ?? [];
const seen = new Set<number>();
return books.filter(book => {
if (seen.has(book.id)) {
return false;
}
seen.add(book.id);
return true;
});
}