From dcf426ac52076138b5606ddad4c2b000439a1e00 Mon Sep 17 00:00:00 2001 From: Yuri Tatishchev Date: Thu, 5 Feb 2026 23:07:08 -0800 Subject: [PATCH] list page pt. 9 fix LIST_QUERY_LIMIT discrepancy --- src/routes/list/+page.svelte | 4 +--- src/routes/list/+page.ts | 7 +++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/routes/list/+page.svelte b/src/routes/list/+page.svelte index 8f56e57..3e4fc1e 100644 --- a/src/routes/list/+page.svelte +++ b/src/routes/list/+page.svelte @@ -10,8 +10,6 @@ } from "$lib/types/mal"; import type { PageData } from "./$types"; - const LIST_QUERY_LIMIT = 20; - const ListSearchSchema = MalAnimeListQuerySchema.extend({ // Allow empty string to mean "All" status: MalAnimeListStatusEnum.or(z.literal("")).default(""), @@ -111,7 +109,7 @@
{#if data.username} - MAL entries: {data.malResponse?.data.length ?? 0} (limited to {LIST_QUERY_LIMIT}) + MAL entries: {data.malResponse?.data.length ?? 0} (limited to {data.LIST_QUERY_LIMIT}) • Songs found: {data.songRows.length} {/if}
diff --git a/src/routes/list/+page.ts b/src/routes/list/+page.ts index f803302..9d66024 100644 --- a/src/routes/list/+page.ts +++ b/src/routes/list/+page.ts @@ -9,7 +9,7 @@ import { } from "$lib/types/mal"; import type { PageLoad } from "./$types"; -const MAL_LIMIT = 20; +const LIST_QUERY_LIMIT = 20; const SearchSchema = MalAnimeListQuerySchema.extend({ // Username @@ -45,6 +45,7 @@ export const load: PageLoad = async ({ url, fetch, depends }) => { // Always return a stable shape for hydration if (!username) { return { + LIST_QUERY_LIMIT, username: "", status: status ?? null, malResponse: null as z.infer | null, @@ -58,7 +59,7 @@ export const load: PageLoad = async ({ url, fetch, depends }) => { url.origin, ); - malUrl.searchParams.set("limit", String(MAL_LIMIT)); + malUrl.searchParams.set("limit", String(LIST_QUERY_LIMIT)); if (status) malUrl.searchParams.set("status", status); // NOTE: If you later want to support sort/offset, add them here from SearchSchema too. @@ -75,6 +76,7 @@ export const load: PageLoad = async ({ url, fetch, depends }) => { // Client-only DB: on the server `db` is null, so return [] and let hydration re-run load in browser. if (!db) { return { + LIST_QUERY_LIMIT, username, status: status ?? null, malResponse, @@ -89,6 +91,7 @@ export const load: PageLoad = async ({ url, fetch, depends }) => { const songRows = await getSongsForMalAnimeIds(db, malIds); return { + LIST_QUERY_LIMIT, username, status: status ?? null, malResponse,