diff --git a/src/routes/list/+page.svelte b/src/routes/list/+page.svelte index 2c29db7..843590c 100644 --- a/src/routes/list/+page.svelte +++ b/src/routes/list/+page.svelte @@ -11,9 +11,13 @@ import { MalAnimeListQuerySchema, MalAnimeListResponseSchema, + MalAnimeListStatusEnum, } from "$lib/types/mal"; + const LIST_QUERY_LIMIT = 1000; + const ListSearchSchema = MalAnimeListQuerySchema.extend({ + status: MalAnimeListStatusEnum.or(z.literal("")).default(""), mal: z.string().default(""), }).strict(); @@ -44,25 +48,25 @@ let songRows = $state([]); /** - * Fetch MAL animelist (limited to 20 for now). + * Fetch MAL animelist (limited to LIST_QUERY_LIMIT for now). * Uses zod schema parsing to avoid redefining types. */ async function fetchMalAnimeList(username: string) { const u = username.trim(); if (!u) return null; - // Always limit to 20 for now; we'll add pagination later. + // Always limit to LIST_QUERY_LIMIT for now; we'll add pagination later. const upstream = new URL( `/api/mal/animelist/${encodeURIComponent(u)}`, window.location.origin, ); - // Forward optional query params (status/sort/offset) while forcing limit=20 + // Forward optional query params (status/sort/offset) while forcing limit=LIST_QUERY_LIMIT if (params.status) upstream.searchParams.set("status", params.status); if (params.sort) upstream.searchParams.set("sort", params.sort); if (params.offset !== undefined) upstream.searchParams.set("offset", String(params.offset)); - upstream.searchParams.set("limit", "20"); + upstream.searchParams.set("limit", LIST_QUERY_LIMIT.toString()); const res = await fetch(upstream); if (!res.ok) { @@ -161,8 +165,8 @@

Enter a MAL username in the URL as /list?mal=USERNAME. This will fetch up to 20 anime from MAL (for now) and then query your local - client DB for related songs. + >. This will fetch up to {LIST_QUERY_LIMIT} anime from MAL (for now) and then query + your local client DB for related songs.

{#if status === "loading"} @@ -192,7 +196,7 @@ {#if isLoadingMal} Fetching MAL list… {:else} - MAL entries: {malEntries.length} (limited to 20) + MAL entries: {malEntries.length} (limited to {LIST_QUERY_LIMIT}) {/if} {" • "} {#if isLoadingDb}