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

2
backend/Cargo.lock generated
View File

@@ -1558,7 +1558,7 @@ checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
[[package]] [[package]]
name = "mangalord" name = "mangalord"
version = "0.120.0" version = "0.121.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"argon2", "argon2",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "mangalord" name = "mangalord"
version = "0.120.0" version = "0.121.0"
edition = "2021" edition = "2021"
default-run = "mangalord" default-run = "mangalord"

View File

@@ -1,6 +1,6 @@
{ {
"name": "mangalord-frontend", "name": "mangalord-frontend",
"version": "0.120.0", "version": "0.121.0",
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {

View File

@@ -7,6 +7,8 @@
import CollectionsGrid from '$lib/components/CollectionsGrid.svelte'; import CollectionsGrid from '$lib/components/CollectionsGrid.svelte';
import PageTagsList from '$lib/components/PageTagsList.svelte'; import PageTagsList from '$lib/components/PageTagsList.svelte';
import HistoryList from '$lib/components/HistoryList.svelte'; import HistoryList from '$lib/components/HistoryList.svelte';
import ListRowSkeleton from '$lib/components/ListRowSkeleton.svelte';
import MangaGridSkeleton from '$lib/components/MangaGridSkeleton.svelte';
let { data } = $props(); let { data } = $props();
@@ -66,37 +68,42 @@
/> />
</div> </div>
{#if !data.authenticated} {#await data.result}
{#if activeTab === 'collections'}
<MangaGridSkeleton count={6} />
{:else}
<ListRowSkeleton />
{/if}
{:then r}
{#if !r.authenticated}
<p class="hint" data-testid="library-signin"> <p class="hint" data-testid="library-signin">
<a href="/login?next=/library">Sign in</a> to see your library. <a href="/login?next=/library">Sign in</a> to see your library.
</p> </p>
{:else if data.error} {:else if r.error}
<p class="error" role="alert" data-testid="library-error"> <p class="error" role="alert" data-testid="library-error">
Couldn't load library: {data.error} Couldn't load library: {r.error}
</p> </p>
{:else if activeTab === 'bookmarks'} {:else if activeTab === 'bookmarks'}
{#if data.bookmarks.length === 0} {#if r.bookmarks.length === 0}
<p class="hint" data-testid="library-bookmarks-empty">No bookmarks yet.</p> <p class="hint" data-testid="library-bookmarks-empty">No bookmarks yet.</p>
{:else} {:else}
<BookmarkList bookmarks={data.bookmarks} testid="library-bookmark-list" /> <BookmarkList bookmarks={r.bookmarks} testid="library-bookmark-list" />
{/if} {/if}
{:else if activeTab === 'collections'} {:else if activeTab === 'collections'}
{#if data.collections.length === 0} {#if r.collections.length === 0}
<p class="hint" data-testid="library-collections-empty"> <p class="hint" data-testid="library-collections-empty">
You don't have any collections yet. Open any manga and use You don't have any collections yet. Open any manga and use
<strong>Add to collection</strong> to start one. <strong>Add to collection</strong> to start one.
</p> </p>
{:else} {:else}
<CollectionsGrid collections={data.collections} /> <CollectionsGrid collections={r.collections} />
{/if} {/if}
{:else if activeTab === 'page-tags'} {:else if activeTab === 'page-tags'}
<PageTagsList <PageTagsList initialItems={r.pageTags} initialDistinct={r.distinctPageTags} />
initialItems={data.pageTags} {:else}
initialDistinct={data.distinctPageTags} <HistoryList entries={r.history} onClear={clearOne} testid="library-history" />
/> {/if}
{:else} {/await}
<HistoryList entries={data.history} onClear={clearOne} testid="library-history" />
{/if}
<style> <style>
.library-heading { .library-heading {

View File

@@ -26,6 +26,10 @@ export const load: PageLoad = async () => {
distinctPageTags: [] as Awaited<ReturnType<typeof listMyDistinctPageTags>>, distinctPageTags: [] as Awaited<ReturnType<typeof listMyDistinctPageTags>>,
error: null as string | null error: null as string | null
}; };
// 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 { try {
const [bookmarks, collections, history, pageTags, distinctPageTags] = const [bookmarks, collections, history, pageTags, distinctPageTags] =
await Promise.all([ await Promise.all([
@@ -52,4 +56,6 @@ export const load: PageLoad = async () => {
} }
throw e; throw e;
} }
})()
};
}; };