feat: loading skeletons on the bookmarks and collections pages

Both loaders now stream the whole result (the single fetch is also the auth
gate) so the page shows a skeleton while it loads instead of the global nav
bar only: a ListRowSkeleton on bookmarks and a MangaGridSkeleton on the
collections grid, resolving to the sign-in / error / empty / list branches.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-07-07 07:18:43 +02:00
parent 5b51bcf056
commit 16cdec051a
10 changed files with 212 additions and 63 deletions

View File

@@ -5,21 +5,27 @@ import type { PageLoad } from './$types';
export const ssr = false;
export const load: PageLoad = async () => {
try {
const page = await listMyBookmarks();
return { bookmarks: page.items, authenticated: true, error: null };
} catch (e) {
if (e instanceof ApiError && e.status === 401) {
return { bookmarks: [], authenticated: false, error: null };
}
// Anything else (502 upstream_unavailable from a backend
// restart, 500 internal_error) is rendered inline rather than
// re-thrown — SvelteKit's generic error.html is not the right
// UX for a transient API blip and the user is already
// authenticated as far as we know.
if (e instanceof ApiError) {
return { bookmarks: [], authenticated: true, error: e.message };
}
throw e;
}
// Streamed (the load itself doesn't await) so the list shows a skeleton
// while the single fetch — which is also the auth gate — is in flight.
return {
result: (async () => {
try {
const page = await listMyBookmarks();
return { bookmarks: page.items, authenticated: true, error: null as string | null };
} catch (e) {
if (e instanceof ApiError && e.status === 401) {
return { bookmarks: [], authenticated: false, error: null as string | null };
}
// Anything else (502 upstream_unavailable from a backend
// restart, 500 internal_error) is rendered inline rather than
// re-thrown — SvelteKit's generic error.html is not the right
// UX for a transient API blip and the user is already
// authenticated as far as we know.
if (e instanceof ApiError) {
return { bookmarks: [], authenticated: true, error: e.message };
}
throw e;
}
})()
};
};