ui: list: add song type filter
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
MalAnimeListResponseSchema,
|
||||
MalAnimeListStatusEnum,
|
||||
} from "$lib/types/mal";
|
||||
import { songTypesCodec } from "../songs/schema";
|
||||
import type { PageLoad } from "./$types";
|
||||
|
||||
const LIST_QUERY_LIMIT = 1000;
|
||||
@@ -17,6 +18,7 @@ const SearchSchema = MalAnimeListQuerySchema.extend({
|
||||
|
||||
// Allow empty string to mean "All"
|
||||
status: MalAnimeListStatusEnum.or(z.literal("")).optional(),
|
||||
type: songTypesCodec.optional(),
|
||||
}).strict();
|
||||
|
||||
type StatusParam = z.infer<typeof SearchSchema>["status"];
|
||||
@@ -39,6 +41,7 @@ export const load: PageLoad = async ({ url, fetch, depends }) => {
|
||||
const status = parsed.success
|
||||
? normalizeStatus(parsed.data.status)
|
||||
: undefined;
|
||||
const types = parsed.success ? parsed.data.type : undefined;
|
||||
|
||||
const username = (mal ?? "").trim();
|
||||
|
||||
@@ -88,7 +91,7 @@ export const load: PageLoad = async ({ url, fetch, depends }) => {
|
||||
await ensureSeeded({ fetch });
|
||||
|
||||
const malIds = malResponse.data.map((e) => e.node.id);
|
||||
const songRows = await getSongsForMalAnimeIds(db, malIds);
|
||||
const songRows = await getSongsForMalAnimeIds(db, malIds, types);
|
||||
|
||||
return {
|
||||
LIST_QUERY_LIMIT,
|
||||
|
||||
Reference in New Issue
Block a user