fix: paginate the bookmarks and collections lists with Load more

Both lists fetched a single capped page (100 / 200) with no pager, so entries
past the cap were silently unreachable. Add a reusable LoadMore component that
seeds from the streamed first page (preserving the auth gate + inline error
handling) and fetches further offset-based pages on demand, and wire it into
the bookmarks and collections pages.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-07-11 15:12:03 +02:00
parent c308eb3eac
commit 3ca05dcb58
8 changed files with 293 additions and 11 deletions

View File

@@ -1,8 +1,15 @@
<script lang="ts">
import BookmarkList from '$lib/components/BookmarkList.svelte';
import ListRowSkeleton from '$lib/components/ListRowSkeleton.svelte';
import LoadMore from '$lib/components/LoadMore.svelte';
import { listMyBookmarks, type Bookmark } from '$lib/api/bookmarks';
let { data } = $props();
async function fetchMore(offset: number) {
const p = await listMyBookmarks({ limit: data.pageSize, offset });
return { items: p.items, total: p.page.total };
}
</script>
<h1>Bookmarks</h1>
@@ -21,7 +28,11 @@
{:else if r.bookmarks.length === 0}
<p class="hint" data-testid="bookmarks-empty">No bookmarks yet.</p>
{:else}
<BookmarkList bookmarks={r.bookmarks} />
<LoadMore initial={r.bookmarks as Bookmark[]} total={r.total} {fetchMore}>
{#snippet children(items: Bookmark[])}
<BookmarkList bookmarks={items} />
{/snippet}
</LoadMore>
{/if}
{/await}