list page pt. 9 fix LIST_QUERY_LIMIT discrepancy
This commit is contained in:
@@ -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