This commit is contained in:
Luc Mcgrady 2025-10-04 17:30:58 +01:00
parent 0db28a7101
commit c76f013b16
No known key found for this signature in database
GPG key ID: 4F3D7A0B17CC3D9C
2 changed files with 6 additions and 5 deletions

View file

@ -720,6 +720,7 @@ post_handlers = {
for handler in exposed_backend_list
}
def _extract_collection_post_request(path: str) -> DynamicRequest | NotFound:
if not aqt.mw.col:
return NotFound(message=f"collection not open, ignore request for {path}")
@ -767,7 +768,7 @@ def _check_dynamic_request_permissions():
"/_anki/i18nResources",
"/_anki/congratsInfo",
# TODO: Unsure about this
"/_anki/nextCardData"
"/_anki/nextCardData",
):
pass
else:

View file

@ -1,6 +1,6 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import { CardAnswer, SchedulingStates } from "@generated/anki/scheduler_pb";
import type { CardAnswer, SchedulingStates } from "@generated/anki/scheduler_pb";
import { nextCardData } from "@generated/backend";
import { bridgeCommand } from "@tslib/bridgecommand";
import { writable } from "svelte/store";
@ -8,20 +8,20 @@ import { writable } from "svelte/store";
export function setupReviewer(iframe: HTMLIFrameElement) {
const cardClass = writable("");
let answer_html = "";
let states: SchedulingStates | undefined;
let _states: SchedulingStates | undefined = undefined;
function updateHtml(htmlString) {
iframe.contentWindow?.postMessage({ type: "html", value: htmlString }, "*");
}
async function showQuestion(answer: CardAnswer | null) {
let resp = await nextCardData({
const resp = await nextCardData({
answer: answer || undefined,
});
// TODO: "Congratulation screen" logic
const question = resp.nextCard?.front || "";
answer_html = resp.nextCard?.back || "";
states = resp.nextCard?.states;
_states = resp.nextCard?.states;
console.log({ resp });
updateHtml(question);
}