list page pt. 8 cleanup

This commit is contained in:
2026-02-05 22:41:46 -08:00
parent 2f0426ce2e
commit 6dc84f544b

View File

@@ -27,12 +27,7 @@
let { data }: { data: PageData } = $props(); let { data }: { data: PageData } = $props();
// Local username field that does NOT update the URL as you type. // Local username field that does NOT update the URL as you type.
let formMal = $state<string>(""); let formMal = $state<string>(params.mal);
// Keep form input synced with navigation (back/forward) and initial load.
$effect(() => {
formMal = data.username || params.mal || "";
});
// If SSR returned no songRows (because client DB wasn't available), // If SSR returned no songRows (because client DB wasn't available),
// re-run load on the client once the DB is ready by invalidating. // re-run load on the client once the DB is ready by invalidating.
@@ -46,11 +41,6 @@
} }
}); });
function onSearch() {
// Only update username param on explicit Search
params.mal = formMal;
}
function songArtistLabel(r: (typeof data.songRows)[number]) { function songArtistLabel(r: (typeof data.songRows)[number]) {
return r.artistName ?? r.groupName ?? null; return r.artistName ?? r.groupName ?? null;
} }
@@ -63,17 +53,16 @@
<h1 class="text-2xl font-semibold">MAL List → Songs</h1> <h1 class="text-2xl font-semibold">MAL List → Songs</h1>
<p class="mt-2 text-sm text-muted-foreground"> <p class="mt-2 text-sm text-muted-foreground">
Enter a MAL username in the URL as {#if !clientDb}
<code class="rounded bg-muted px-1 py-0.5">/list?mal=USERNAME</code>. This Loading DB...
loads up to {LIST_QUERY_LIMIT} anime from MAL (for now) and then queries your local {/if}
client DB for related songs.
</p> </p>
<form <form
class="mt-4 flex flex-col gap-2" class="mt-4 flex flex-col gap-2"
onsubmit={(e) => { onsubmit={(e) => {
e.preventDefault(); e.preventDefault();
onSearch(); params.mal = formMal;
}} }}
> >
<div class="flex flex-wrap gap-2"> <div class="flex flex-wrap gap-2">
@@ -85,8 +74,7 @@
id="mal-user" id="mal-user"
class="rounded border px-3 py-2 text-sm" class="rounded border px-3 py-2 text-sm"
placeholder="e.g. CaZzzer" placeholder="e.g. CaZzzer"
value={formMal} bind:value={formMal}
oninput={(e) => (formMal = (e.currentTarget as HTMLInputElement).value)}
autocomplete="off" autocomplete="off"
spellcheck={false} spellcheck={false}
/> />
@@ -122,9 +110,7 @@
</div> </div>
<div class="text-sm text-muted-foreground"> <div class="text-sm text-muted-foreground">
{#if !data.username} {#if data.username}
Waiting for username…
{:else}
MAL entries: {data.malResponse?.data.length ?? 0} (limited to {LIST_QUERY_LIMIT}) MAL entries: {data.malResponse?.data.length ?? 0} (limited to {LIST_QUERY_LIMIT})
• Songs found: {data.songRows.length} • Songs found: {data.songRows.length}
{/if} {/if}