From 8cb04e0295daaafd65491da07ee6265b29fb9974 Mon Sep 17 00:00:00 2001 From: Yuri Tatishchev Date: Fri, 6 Feb 2026 11:37:39 -0800 Subject: [PATCH] song type schema stuff --- src/routes/songs/+page.svelte | 89 ++++++++++++++++++----------------- src/routes/songs/+page.ts | 4 +- src/routes/songs/schema.ts | 9 +++- 3 files changed, 57 insertions(+), 45 deletions(-) diff --git a/src/routes/songs/+page.svelte b/src/routes/songs/+page.svelte index 67e7f48..2647a6e 100644 --- a/src/routes/songs/+page.svelte +++ b/src/routes/songs/+page.svelte @@ -15,9 +15,9 @@ import { addAllToQueue, playAllNext } from "$lib/player/player.svelte"; import { trackFromSongRow } from "$lib/player/types"; import type { PageData } from "./$types"; - import { SearchParamsSchema } from "./schema"; + import { SearchParamsSchemaClient } from "./schema"; - const params = useSearchParams(SearchParamsSchema, { + const params = useSearchParams(SearchParamsSchemaClient, { pushHistory: false, showDefaults: false, }); @@ -135,49 +135,54 @@ {#if data.songRows.length > 0} -
- +
+
+ - + - {#if tracksFromResults.length !== data.songRows.length} - - ({tracksFromResults.length} playable) - - {/if} + {#if tracksFromResults.length !== data.songRows.length} + + ({tracksFromResults.length} playable) + + {/if} +
+ +
+

Songs

+ {data.songRows.length} +
+ +
    + {#each data.songRows as r (r.annSongId)} +
  • + +
  • + {/each} +
- -

Songs

- - {:else if Object.values(params).some((val) => (Array.isArray(val) && val.length > 0) || (typeof val === "string" && val.trim() !== "") || typeof val === "number")}

No songs found matching your criteria. diff --git a/src/routes/songs/+page.ts b/src/routes/songs/+page.ts index ee8476e..e75240a 100644 --- a/src/routes/songs/+page.ts +++ b/src/routes/songs/+page.ts @@ -1,12 +1,12 @@ import type { SongFilters } from "$lib/db/client-db"; import { db, ensureSeeded, getSongsWithFilters } from "$lib/db/client-db"; import type { PageLoad } from "./$types"; -import { SearchParamsSchema } from "./schema"; +import { SearchParamsSchemaServer } from "./schema"; export const load: PageLoad = async ({ url, fetch, depends }) => { depends("clientdb:songs"); - const parsed = SearchParamsSchema.safeParse( + const parsed = SearchParamsSchemaServer.safeParse( Object.fromEntries(url.searchParams.entries()), ); diff --git a/src/routes/songs/schema.ts b/src/routes/songs/schema.ts index 2541077..080a39f 100644 --- a/src/routes/songs/schema.ts +++ b/src/routes/songs/schema.ts @@ -6,5 +6,12 @@ export const SearchParamsSchema = z.object({ anime: z.string().optional().default(""), gpm: z.coerce.number().int().optional().default(0), gpx: z.coerce.number().int().optional().default(100), - songType: z.coerce.number().int().optional().default(0), +}); + +export const SearchParamsSchemaClient = SearchParamsSchema.extend({ + songType: z.string().optional().default("0"), +}); + +export const SearchParamsSchemaServer = SearchParamsSchema.extend({ + songType: z.coerce.number().int().optional(), });