Fix adding/saving I/Os on mobile
This commit is contained in:
parent
a90eda2e53
commit
a188a59646
|
@ -1,8 +1,17 @@
|
||||||
// Copyright: Ankitects Pty Ltd and contributors
|
// Copyright: Ankitects Pty Ltd and contributors
|
||||||
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
|
import { get } from "svelte/store";
|
||||||
|
|
||||||
|
import { addOrUpdateNote } from "../add-or-update-note";
|
||||||
import type { IOMode } from "../lib";
|
import type { IOMode } from "../lib";
|
||||||
|
import { hideAllGuessOne } from "../store";
|
||||||
import type { PageLoad } from "./$types";
|
import type { PageLoad } from "./$types";
|
||||||
|
|
||||||
|
async function save(): Promise<void> {
|
||||||
|
addOrUpdateNote(globalThis["anki"].imageOcclusion.mode, get(hideAllGuessOne));
|
||||||
|
}
|
||||||
|
|
||||||
export const load = (async ({ params }) => {
|
export const load = (async ({ params }) => {
|
||||||
let mode: IOMode;
|
let mode: IOMode;
|
||||||
if (/^\d+/.test(params.imagePathOrNoteId)) {
|
if (/^\d+/.test(params.imagePathOrNoteId)) {
|
||||||
|
@ -10,6 +19,14 @@ export const load = (async ({ params }) => {
|
||||||
} else {
|
} else {
|
||||||
mode = { kind: "add", imagePath: params.imagePathOrNoteId, notetypeId: 0 };
|
mode = { kind: "add", imagePath: params.imagePathOrNoteId, notetypeId: 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// for adding note from mobile devices
|
||||||
|
globalThis.anki = globalThis.anki || {};
|
||||||
|
globalThis.anki.imageOcclusion = {
|
||||||
|
mode,
|
||||||
|
save,
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
mode,
|
mode,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue