feat: show books as an import adds them, not once it ends

Refresh the list every couple of seconds while the queue runs, holding off
while the reader has scrolled past the first page.
This commit is contained in:
2026-08-17 11:21:49 -04:00
parent 7e33a8fe05
commit 85367daf7e
3 changed files with 65 additions and 0 deletions
@@ -29,6 +29,12 @@ export class BookCollectionState {
private currentBookPage = $state(1);
public loading = $state(false);
/**
* Whether the reader has loaded past the first page. Anything that refetches
* gets page one back, which is a jump to the top from here.
*/
readonly pastFirstPage = $derived(this.currentBookPage > 1);
public filterOptions: FilterOption[] = $state([]);
private ops: BookOperationsState;
@@ -187,6 +193,11 @@ export class BookCollectionState {
this.moreBooks = books.total > books.items.length;
this.filterOptions = this.buildFilterOptions(filterData);
// The loader hands back the first page, so the counter has to say so —
// otherwise loadMoreBooks resumes from wherever the reader had scrolled to
// and skips every page in between.
this.currentBookPage = 1;
const urlParams = new URLSearchParams(window.location.search);
// Re-read sort and filter state from URL