From a144baba2becde02a903f356ff5f729384640b3b Mon Sep 17 00:00:00 2001 From: Yuri Tatishchev Date: Fri, 13 Feb 2026 00:32:47 -0800 Subject: [PATCH] list: prototype without nested params --- src/routes/list/+page.svelte | 50 ++++++++++++++++++++++-------------- src/routes/list/schema.ts | 22 +++++++--------- src/routes/songs/schema.ts | 8 +++--- 3 files changed, 44 insertions(+), 36 deletions(-) diff --git a/src/routes/list/+page.svelte b/src/routes/list/+page.svelte index 540ce87..d09f5e2 100644 --- a/src/routes/list/+page.svelte +++ b/src/routes/list/+page.svelte @@ -4,32 +4,44 @@ import { SearchParamsSchema } from "./schema"; import { ChipGroup } from "$lib/components/ui/chip-group"; import { AnimeListWatchStatus } from "$lib/utils/list"; + import NativeSelect from "$lib/components/ui/native-select/native-select.svelte"; + import NativeSelectOption from "$lib/components/ui/native-select/native-select-option.svelte"; + import Input from "$lib/components/ui/input/input.svelte"; + import { Label } from "$lib/components/ui/label"; + import { Button } from "$lib/components/ui/button"; let { data }: { data: PageData } = $props(); const params = useSearchParams(SearchParamsSchema, { - pushHistory: false, + showDefaults: true, + updateURL: false, });

List Search WIP

-
- - - - - - ({ - label: v.toUpperCase(), - value: v, - }))} - bind:value={params.list.status} - /> + +
+ + + MAL + AniList + Kitsu + +
+
+ + +
+
+ + ({ + label: v.toUpperCase(), + value: v, + }))} + bind:value={params.status} + /> +
+ diff --git a/src/routes/list/schema.ts b/src/routes/list/schema.ts index 425652d..df969b0 100644 --- a/src/routes/list/schema.ts +++ b/src/routes/list/schema.ts @@ -1,19 +1,15 @@ -import { AnimeList, AnimeListWatchStatus } from "$lib/utils/list"; +import { AnimeListKind, AnimeListWatchStatus } from "$lib/utils/list"; import { z } from "zod"; -const fieldSep = ":"; -const valueSep = ","; +const valueSep = "."; -const listCodec = z.codec(z.string(), AnimeList, { - decode: (s) => { - const [kind, ...rest] = decodeURIComponent(s).split(fieldSep); - const status = rest.pop()?.split(valueSep).map((v) => AnimeListWatchStatus.parse(v)) ?? []; - const username = rest.join(""); - return AnimeList.parse({ kind, username, status }); - }, - encode: (list) => encodeURIComponent(`${list.kind}${fieldSep}${list.username}${fieldSep}${list.status?.join(valueSep)}`), -}); +const statusCodec = z.codec(z.string(), z.array(AnimeListWatchStatus), { + decode: (s) => s ? decodeURIComponent(s).split(valueSep).map((s) => AnimeListWatchStatus.parse(s)) : [], + encode: (v) => v.length ? encodeURIComponent(v.join(valueSep)) : "", +}) export const SearchParamsSchema = z.object({ - list: listCodec.default({ kind: "mal", username: "", status: [] }), + kind: AnimeListKind.default("mal"), + username: z.string().optional().default(""), + status: statusCodec.default([]), }) diff --git a/src/routes/songs/schema.ts b/src/routes/songs/schema.ts index 93ceb73..945e987 100644 --- a/src/routes/songs/schema.ts +++ b/src/routes/songs/schema.ts @@ -11,14 +11,14 @@ const songTypesCodec = z.codec(z.string(), z.array(AmqSongLinkType), { decode: (str) => str ? decodeURIComponent(str) - .split(SEP) - .map((s) => AmqSongLinkTypeMap[s as keyof typeof AmqSongLinkTypeMap]) + .split(SEP) + .map((s) => AmqSongLinkTypeMap[s as keyof typeof AmqSongLinkTypeMap]) : [], encode: (arr) => arr ? encodeURIComponent( - arr.map((a) => AmqSongLinkTypeMapReverse[a]).join(SEP), - ) + arr.map((a) => AmqSongLinkTypeMapReverse[a]).join(SEP), + ) : "", });