mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Fix CardInfoPlaceholder not showing when card id is invalid (#3631)
* Catch bigint parsing error * Modify CONTRIBUTORS
This commit is contained in:
parent
2d207ff5ba
commit
a2ad0bce55
1 changed files with 10 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue