Enhance ZXDB releases and caching

Signed-off-by: codex@lucy.xalior.com
This commit is contained in:
2026-01-10 17:05:37 +00:00
parent 208a06c351
commit 5d140a45a7
5 changed files with 519 additions and 41 deletions

View File

@@ -1,5 +1,5 @@
import ReleasesExplorer from "./ReleasesExplorer";
import { searchReleases } from "@/server/repo/zxdb";
import { listCasetypes, listFiletypes, listLanguages, listMachinetypes, listSchemetypes, listSourcetypes, searchReleases } from "@/server/repo/zxdb";
export const metadata = {
title: "ZXDB Releases",
@@ -9,6 +9,7 @@ export const dynamic = "force-dynamic";
export default async function Page({ searchParams }: { searchParams: Promise<{ [key: string]: string | string[] | undefined }> }) {
const sp = await searchParams;
const hasParams = Object.values(sp).some((value) => value !== undefined);
const page = Math.max(1, Number(Array.isArray(sp.page) ? sp.page[0] : sp.page) || 1);
const q = (Array.isArray(sp.q) ? sp.q[0] : sp.q) ?? "";
const yearStr = (Array.isArray(sp.year) ? sp.year[0] : sp.year) ?? "";
@@ -25,8 +26,14 @@ export default async function Page({ searchParams }: { searchParams: Promise<{ [
const isDemoStr = (Array.isArray(sp.isDemo) ? sp.isDemo[0] : sp.isDemo) ?? "";
const isDemo = isDemoStr ? (isDemoStr === "true" || isDemoStr === "1") : undefined;
const [initial] = await Promise.all([
const [initial, langs, machines, filetypes, schemes, sources, cases] = await Promise.all([
searchReleases({ page, pageSize: 20, q, year, sort, dLanguageId: dLanguageId || undefined, dMachinetypeId, filetypeId, schemetypeId: schemetypeId || undefined, sourcetypeId: sourcetypeId || undefined, casetypeId: casetypeId || undefined, isDemo }),
listLanguages(),
listMachinetypes(),
listFiletypes(),
listSchemetypes(),
listSourcetypes(),
listCasetypes(),
]);
// Ensure the object passed to a Client Component is a plain JSON value
@@ -35,7 +42,16 @@ export default async function Page({ searchParams }: { searchParams: Promise<{ [
return (
<ReleasesExplorer
initial={initialPlain}
initialLists={{
languages: JSON.parse(JSON.stringify(langs)),
machinetypes: JSON.parse(JSON.stringify(machines)),
filetypes: JSON.parse(JSON.stringify(filetypes)),
schemetypes: JSON.parse(JSON.stringify(schemes)),
sourcetypes: JSON.parse(JSON.stringify(sources)),
casetypes: JSON.parse(JSON.stringify(cases)),
}}
initialUrlState={{ q, page, year: yearStr, sort, dLanguageId, dMachinetypeId: dMachinetypeIdStr, filetypeId: filetypeIdStr, schemetypeId, sourcetypeId, casetypeId, isDemo: isDemoStr }}
initialUrlHasParams={hasParams}
/>
);
}