mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Fix selected notetype/deck reverting back to defaults
This commit is contained in:
parent
c1a44ce867
commit
ba881d4e90
2 changed files with 14 additions and 9 deletions
|
@ -427,7 +427,7 @@ require("anki/ui").loaded.then(() => require("anki/NoteEditor").instances[0].too
|
|||
gui_hooks.editor_did_load_note(self)
|
||||
|
||||
assert self.mw.pm.profile is not None
|
||||
js = f"loadNote({json.dumps(self.nid)}, {mid}, {json.dumps(focus_to)}, {json.dumps(original_note_id)}, {json.dumps(self.mw.reviewer.card.id if self.mw.reviewer.card else None)});"
|
||||
js = f"loadNote({json.dumps(self.nid)}, {mid}, {json.dumps(focus_to)}, {json.dumps(original_note_id)}, {json.dumps(self.mw.reviewer.card.id if self.mw.reviewer.card else None)}, true);"
|
||||
self.web.evalWithCallback(
|
||||
f'require("anki/ui").loaded.then(() => {{ {js} }})', oncallback
|
||||
)
|
||||
|
|
|
@ -305,7 +305,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
export let selectedDeck: DeckNameId | null = null;
|
||||
|
||||
async function onNotetypeChange(notetype: NotetypeNameId) {
|
||||
loadNote(0n, notetype.id, 0, null, null);
|
||||
loadNote(0n, notetype.id, 0, null, reviewerCard?.id ?? null);
|
||||
if (
|
||||
!(await getConfigBool({
|
||||
key: ConfigKey_Bool.ADDING_DEFAULTS_TO_CURRENT_DECK,
|
||||
|
@ -519,7 +519,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
}
|
||||
|
||||
async function loadNewNote() {
|
||||
await loadNote(0n, notetypeMeta.id, 0, null, null);
|
||||
await loadNote(0n, notetypeMeta.id, 0, null, reviewerCard?.id ?? null);
|
||||
}
|
||||
|
||||
async function noteCanBeAdded(): Promise<boolean> {
|
||||
|
@ -953,6 +953,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
focusTo: number,
|
||||
originalNoteId: bigint | null,
|
||||
reviewerCardId: bigint | null,
|
||||
initial: boolean = false,
|
||||
) {
|
||||
const notetype = await getNotetype({
|
||||
ntid: notetypeId,
|
||||
|
@ -987,11 +988,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
reviewerCard = await getCard({ cid: reviewerCardId });
|
||||
homeDeckId = reviewerCard.originalDeckId || reviewerCard.deckId;
|
||||
}
|
||||
const chooserDefaults = await defaultsForAdding({
|
||||
homeDeckOfCurrentReviewCard: homeDeckId,
|
||||
});
|
||||
notetypeChooser.select(chooserDefaults.notetypeId);
|
||||
deckChooser.select(chooserDefaults.deckId);
|
||||
if (initial) {
|
||||
const chooserDefaults = await defaultsForAdding({
|
||||
homeDeckOfCurrentReviewCard: homeDeckId,
|
||||
});
|
||||
notetypeChooser.select(chooserDefaults.notetypeId);
|
||||
deckChooser.select(chooserDefaults.deckId);
|
||||
}
|
||||
|
||||
const fieldValues = (
|
||||
await Promise.all(
|
||||
|
@ -1073,6 +1076,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
focusTo: number,
|
||||
originalNoteId: bigint | null,
|
||||
reviewerCardId: bigint | null,
|
||||
initial: boolean = false,
|
||||
) {
|
||||
loadDebouncer.schedule(async () => {
|
||||
await loadNoteInner(
|
||||
|
@ -1081,12 +1085,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
focusTo,
|
||||
originalNoteId,
|
||||
reviewerCardId,
|
||||
initial,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
async function reloadNote() {
|
||||
await loadNote(note!.id, notetypeMeta.id, 0, null);
|
||||
await loadNote(note!.id, notetypeMeta.id, 0, null, reviewerCard?.id ?? null);
|
||||
}
|
||||
|
||||
function checkNonLegacy(value: any): any | undefined {
|
||||
|
|
Loading…
Reference in a new issue