list page pt. 9 fix LIST_QUERY_LIMIT discrepancy
This commit is contained in:
@@ -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 @@
|
||||
|
||||
<div class="text-sm text-muted-foreground">
|
||||
{#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}
|
||||
</div>
|
||||
|
||||
@@ -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<typeof MalAnimeListResponseSchema> | 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,
|
||||
|
||||
Reference in New Issue
Block a user