Fix CardInfoPlaceholder not showing when card id is invalid (#3631)

* Catch bigint parsing error

* Modify CONTRIBUTORS
This commit is contained in:
llama 2024-12-14 18:32:51 +08:00 committed by GitHub
parent 2d207ff5ba
commit a2ad0bce55
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,7 +4,16 @@ import { cardStats } from "@generated/backend";
import type { PageLoad } from "./$types";
function optionalBigInt(x: any): bigint | null {
try {
return BigInt(x);
} catch (e) {
return null;
}
}
export const load = (async ({ params }) => {
const info = await cardStats({ cid: BigInt(params.cardId) });
const cid = optionalBigInt(params.cardId);
const info = cid !== null ? await cardStats({ cid }) : null;
return { info };
}) satisfies PageLoad;