refactor(ui): shared browse layer with virtual grid, filter rail and bulk actions (#2570)

This commit is contained in:
Alex
2026-09-26 12:55:44 +01:00
committed by GitHub
parent 839e02fc9a
commit 0780199b4c
57 changed files with 2980 additions and 144 deletions
@@ -301,7 +301,6 @@ export class BookBrowserComponent implements AfterViewInit {
minimumCount: metrics => this.minimumLoadingGridItemCount(metrics),
initialOffset: this.initialScrollOffset,
fillItemWidth: true,
deferViewportUpdates: this.layoutService.sidebarTransitioning,
estimateItemHeight: itemWidth => this.isMobile()
? this.mobileCardSizeForWidth(itemWidth).height
: this.cardSizeForWidth(itemWidth).height,
@@ -1,41 +0,0 @@
import {describe, expect, it} from 'vitest';
import {BookPage, flattenBookPages} from './book-query.models';
function page(ids: number[]): BookPage {
return {
content: ids.map(id => ({id, libraryId: 1, libraryName: 'Library'})),
page: {
number: 0,
size: ids.length,
totalElements: ids.length,
totalPages: 1,
cursor: 'opaque-cursor',
},
links: [],
};
}
describe('flattenBookPages', () => {
it('returns an empty list without data', () => {
expect(flattenBookPages(undefined)).toEqual([]);
});
it('flattens pages in order', () => {
const flattened = flattenBookPages({
pages: [page([1, 2]), page([3, 4])],
pageParams: [null, 'next'],
});
expect(flattened.map(book => book.id)).toEqual([1, 2, 3, 4]);
});
it('keeps the first occurrence when an offset shift re-serves a book', () => {
const flattened = flattenBookPages({
pages: [page([1, 2]), page([2, 3])],
pageParams: [null, 'next'],
});
expect(flattened.map(book => book.id)).toEqual([1, 2, 3]);
});
});
@@ -1,21 +1,5 @@
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;
});
}