From 47423fb529bbe7493c9e635d8a69f1f16112684d Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Fri, 27 Nov 2026 03:23:54 -0500 Subject: [PATCH] =?UTF-8?q?refactor(web):=20Library=20=E2=80=BA=20Albums?= =?UTF-8?q?=20and=20=E2=80=BA=20Artists=20are=20one=20A=E2=80=93Z=20page?= =?UTF-8?q?=20(DRY=20W8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The two pages matched line for line apart from the noun, the filter field and the sort key: the count, the quick filter, the lettered grid paged as you scroll, the admin and listener empty states, and the "search the full library" link when the filter matches nothing loaded. AlphaLibrary now draws them once and each page supplies its query, noun, match, key and card. Co-Authored-By: Claude Opus 5.5 --- web/src/lib/components/AlphaLibrary.svelte | 131 ++++++++++++++++++++ web/src/routes/library/albums/+page.svelte | 106 +++------------- web/src/routes/library/artists/+page.svelte | 106 +++------------- 3 files changed, 160 insertions(+), 183 deletions(-) create mode 100644 web/src/lib/components/AlphaLibrary.svelte diff --git a/web/src/lib/components/AlphaLibrary.svelte b/web/src/lib/components/AlphaLibrary.svelte new file mode 100644 index 00000000..956e9768 --- /dev/null +++ b/web/src/lib/components/AlphaLibrary.svelte @@ -0,0 +1,131 @@ + + +
+
+
+

{title}

+ {#if !query.isPending && !failed} +

{plural(total, one, many)}

+ {/if} +
+ {#if items.length > 0} + + {/if} +
+ + {#if failed} + + {:else if showSkeleton.value && items.length === 0} +

Loading…

+ {:else if !query.isPending && total === 0} + + {#if user.value?.is_admin} + + {#snippet actions()} + + Run a scan + + {/snippet} + + {:else} + + {/if} + {:else if filter.trim() && filtered.length === 0} +

+ No {many} in your loaded library match + '{filter.trim()}'. + + Search the full library → + +

+ {:else} + query.fetchNextPage()} + {item} + /> + + query.fetchNextPage()} + endLabel="End of library" + /> + {/if} +
diff --git a/web/src/routes/library/albums/+page.svelte b/web/src/routes/library/albums/+page.svelte index 04ca50ff..6b92c6b7 100644 --- a/web/src/routes/library/albums/+page.svelte +++ b/web/src/routes/library/albums/+page.svelte @@ -1,104 +1,26 @@ {pageTitle('Library · Albums')} -
-
-
-

Albums

- {#if !query.isPending && !(query.isError && !query.isFetchNextPageError)} -

- {plural(total, 'album', 'albums')} -

- {/if} -
- {#if albums.length > 0} - - {/if} -
- - {#if query.isError && !query.isFetchNextPageError} - - {:else if showSkeleton.value && albums.length === 0} -

Loading…

- {:else if !query.isPending && total === 0} - - {#if user.value?.is_admin} - - {#snippet actions()} - - Run a scan - - {/snippet} - - {:else} - - {/if} - {:else if filter.trim() && filtered.length === 0} -

- No albums in your loaded library match - '{filter.trim()}'. - - Search the full library → - -

- {:else} - a.sort_title || a.title} - hasMore={!!query.hasNextPage} - onLoadMore={() => query.fetchNextPage()} - > - {#snippet item(album: AlbumRef)} - - {/snippet} - - - query.fetchNextPage()} - endLabel="End of library" - /> - {/if} -
+ a.title.toLowerCase().includes(q) || a.artist_name.toLowerCase().includes(q)} + getKey={(a: AlbumRef) => a.sort_title || a.title} + searchPath="/search/albums" +> + {#snippet item(album: AlbumRef)} + + {/snippet} + diff --git a/web/src/routes/library/artists/+page.svelte b/web/src/routes/library/artists/+page.svelte index 88ddf950..c8f34c9a 100644 --- a/web/src/routes/library/artists/+page.svelte +++ b/web/src/routes/library/artists/+page.svelte @@ -1,102 +1,26 @@ {pageTitle('Library · Artists')} -
-
-
-

Artists

- {#if !query.isPending && !(query.isError && !query.isFetchNextPageError)} -

- {plural(total, 'artist', 'artists')} -

- {/if} -
- {#if artists.length > 0} - - {/if} -
- - {#if query.isError && !query.isFetchNextPageError} - - {:else if showSkeleton.value && artists.length === 0} -

Loading…

- {:else if !query.isPending && total === 0} - - {#if user.value?.is_admin} - - {#snippet actions()} - - Run a scan - - {/snippet} - - {:else} - - {/if} - {:else if filter.trim() && filtered.length === 0} -

- No artists in your loaded library match - '{filter.trim()}'. - - Search the full library → - -

- {:else} - a.sort_name || a.name} - hasMore={!!query.hasNextPage} - onLoadMore={() => query.fetchNextPage()} - > - {#snippet item(a: ArtistRef)} - - {/snippet} - - - query.fetchNextPage()} - endLabel="End of library" - /> - {/if} -
+ a.name.toLowerCase().includes(q)} + getKey={(a: ArtistRef) => a.sort_name || a.name} + searchPath="/search/artists" +> + {#snippet item(a: ArtistRef)} + + {/snippet} +