feat: loading skeleton on the library page

The library loader streams its one-shot bundle (also the auth gate), so the
active sub-tab shows a skeleton while it loads — a grid skeleton for the
Collections tab, a row skeleton for Bookmarks/History/Page-tags — instead of
only the global nav bar.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-07-07 07:21:20 +02:00
parent 16cdec051a
commit 3c8e264f48
5 changed files with 68 additions and 55 deletions

View File

@@ -26,30 +26,36 @@ export const load: PageLoad = async () => {
distinctPageTags: [] as Awaited<ReturnType<typeof listMyDistinctPageTags>>,
error: null as string | null
};
try {
const [bookmarks, collections, history, pageTags, distinctPageTags] =
await Promise.all([
listMyBookmarks(),
listMyCollections({ limit: 200 }),
listMyReadProgress({ limit: 100 }),
listMyPageTags({ limit: 100 }),
listMyDistinctPageTags(undefined, 100)
]);
return {
...empty,
bookmarks: bookmarks.items,
collections: collections.items,
history: history.items,
pageTags: pageTags.items,
distinctPageTags
};
} catch (e) {
if (e instanceof ApiError && e.status === 401) {
return { ...empty, authenticated: false };
}
if (e instanceof ApiError) {
return { ...empty, error: e.message };
}
throw e;
}
// Streamed so the active sub-tab shows a skeleton while the one-shot fetch
// (also the auth gate) is in flight.
return {
result: (async () => {
try {
const [bookmarks, collections, history, pageTags, distinctPageTags] =
await Promise.all([
listMyBookmarks(),
listMyCollections({ limit: 200 }),
listMyReadProgress({ limit: 100 }),
listMyPageTags({ limit: 100 }),
listMyDistinctPageTags(undefined, 100)
]);
return {
...empty,
bookmarks: bookmarks.items,
collections: collections.items,
history: history.items,
pageTags: pageTags.items,
distinctPageTags
};
} catch (e) {
if (e instanceof ApiError && e.status === 401) {
return { ...empty, authenticated: false };
}
if (e instanceof ApiError) {
return { ...empty, error: e.message };
}
throw e;
}
})()
};
};