mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00

The move to Sveltekit broke the 'card info during review' add-on and its descendants. This didn't get noticed in 24.11 due to the old card-info.js file still being shipped. I considered adding back the card-info.js generation, but it ended up being simpler to move parts of the add-on into a separate page instead. This is a stop-gap solution - in the future I'd like to get us to a point where such component compositions can be done by add-ons, and don't need to be done as part of Anki's build process. Related: #3187
22 lines
757 B
TypeScript
22 lines
757 B
TypeScript
// Copyright: Ankitects Pty Ltd and contributors
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
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 currentId = optionalBigInt(params.cardId);
|
|
const currentInfo = currentId !== null ? await cardStats({ cid: currentId }) : null;
|
|
const previousId = optionalBigInt(params.previousId);
|
|
const previousInfo = previousId !== null ? await cardStats({ cid: previousId }) : null;
|
|
return { currentInfo, previousInfo };
|
|
}) satisfies PageLoad;
|