You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: page the library UI through the backend book query (#117)
The cover grid no longer loads every book at startup. The library store
now keeps a paged query cache keyed by the serialized filter combination
(text, author_id, series_id, hide_read, sort): each entry holds the
filtered total plus a sparse map of 100-book pages, fetched on demand via
clbQueryBooks as the virtualized grid scrolls (ensureBookRange, with
in-flight de-dupe and generation stamps so stale fetches never land).
Mutations stop refetching the whole library; they invalidate the cache so
visible pages reload lazily. Search text debounces ~200ms before becoming
a new cache key; sorting and hide-read now run in SQL via the query params.
Deep links carry ids instead of names: the Authors page and book-detail
author links pass author_id, and series links pass series_id, resolved
through a new minimal clb_query_list_series command (the only way to map
series names to the ids LibraryBookQuery filters on; it also lets the
Series page drop its full-book-list dependency). A series filter fetches
the whole series unpaged and sorts by series_index client-side, since the
backend only sorts by title/author.
clb_query_list_all_books stays for the Authors page (per-author book
counts need every book-author link) and the book detail route (tag
autocomplete needs the full tag vocabulary; no fetch-one-book command),
both now loaded lazily on first use via useAllBooks.
The pure cache logic lives in src/lib/book-page-cache.ts with vitest
coverage for key serialization, page math, range-to-pages, sparse
flattening, and generation invalidation.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
// biome-ignore lint/suspicious/noArrayIndexKey: an unfetched slot has no id; its flat grid index IS its identity until the book arrives (and then the keyed BookCard replaces it).
0 commit comments