list page pt. 9 fix LIST_QUERY_LIMIT discrepancy

This commit is contained in:
2026-02-05 23:07:08 -08:00
parent 6dc84f544b
commit dcf426ac52
2 changed files with 6 additions and 5 deletions

View File

@@ -10,8 +10,6 @@
} from "$lib/types/mal"; } from "$lib/types/mal";
import type { PageData } from "./$types"; import type { PageData } from "./$types";
const LIST_QUERY_LIMIT = 20;
const ListSearchSchema = MalAnimeListQuerySchema.extend({ const ListSearchSchema = MalAnimeListQuerySchema.extend({
// Allow empty string to mean "All" // Allow empty string to mean "All"
status: MalAnimeListStatusEnum.or(z.literal("")).default(""), status: MalAnimeListStatusEnum.or(z.literal("")).default(""),
@@ -111,7 +109,7 @@
<div class="text-sm text-muted-foreground"> <div class="text-sm text-muted-foreground">
{#if data.username} {#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} • Songs found: {data.songRows.length}
{/if} {/if}
</div> </div>

View File

@@ -9,7 +9,7 @@ import {
} from "$lib/types/mal"; } from "$lib/types/mal";
import type { PageLoad } from "./$types"; import type { PageLoad } from "./$types";
const MAL_LIMIT = 20; const LIST_QUERY_LIMIT = 20;
const SearchSchema = MalAnimeListQuerySchema.extend({ const SearchSchema = MalAnimeListQuerySchema.extend({
// Username // Username
@@ -45,6 +45,7 @@ export const load: PageLoad = async ({ url, fetch, depends }) => {
// Always return a stable shape for hydration // Always return a stable shape for hydration
if (!username) { if (!username) {
return { return {
LIST_QUERY_LIMIT,
username: "", username: "",
status: status ?? null, status: status ?? null,
malResponse: null as z.infer<typeof MalAnimeListResponseSchema> | null, malResponse: null as z.infer<typeof MalAnimeListResponseSchema> | null,
@@ -58,7 +59,7 @@ export const load: PageLoad = async ({ url, fetch, depends }) => {
url.origin, url.origin,
); );
malUrl.searchParams.set("limit", String(MAL_LIMIT)); malUrl.searchParams.set("limit", String(LIST_QUERY_LIMIT));
if (status) malUrl.searchParams.set("status", status); if (status) malUrl.searchParams.set("status", status);
// NOTE: If you later want to support sort/offset, add them here from SearchSchema too. // 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. // Client-only DB: on the server `db` is null, so return [] and let hydration re-run load in browser.
if (!db) { if (!db) {
return { return {
LIST_QUERY_LIMIT,
username, username,
status: status ?? null, status: status ?? null,
malResponse, malResponse,
@@ -89,6 +91,7 @@ export const load: PageLoad = async ({ url, fetch, depends }) => {
const songRows = await getSongsForMalAnimeIds(db, malIds); const songRows = await getSongsForMalAnimeIds(db, malIds);
return { return {
LIST_QUERY_LIMIT,
username, username,
status: status ?? null, status: status ?? null,
malResponse, malResponse,