mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
Only reload note on reopen if empty
This commit is contained in:
parent
ba881d4e90
commit
efe76a24dc
3 changed files with 12 additions and 1 deletions
|
@ -63,7 +63,7 @@ class NewAddCards(QMainWindow):
|
|||
)
|
||||
|
||||
def reopen(self, mw: AnkiQt) -> None:
|
||||
self.editor.reload_note()
|
||||
self.editor.reload_note_if_empty()
|
||||
|
||||
def helpRequested(self) -> None:
|
||||
openHelp(HelpPage.ADDING_CARD_AND_NOTE)
|
||||
|
|
|
@ -435,6 +435,9 @@ require("anki/ui").loaded.then(() => require("anki/NoteEditor").instances[0].too
|
|||
def reload_note(self) -> None:
|
||||
self.web.eval("reloadNote();")
|
||||
|
||||
def reload_note_if_empty(self) -> None:
|
||||
self.web.eval("reloadNoteIfEmpty();")
|
||||
|
||||
def call_after_note_saved(
|
||||
self, callback: Callable, keepFocus: bool = False
|
||||
) -> None:
|
||||
|
|
|
@ -1094,6 +1094,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
await loadNote(note!.id, notetypeMeta.id, 0, null, reviewerCard?.id ?? null);
|
||||
}
|
||||
|
||||
async function reloadNoteIfEmpty() {
|
||||
const isEmpty = (await noteFieldsCheck(note!)).state == NoteFieldsCheckResponse_State.EMPTY;
|
||||
if (isEmpty) {
|
||||
await loadNote(note!.id, notetypeMeta.id, 0, null, reviewerCard?.id ?? null, true);
|
||||
}
|
||||
}
|
||||
|
||||
function checkNonLegacy(value: any): any | undefined {
|
||||
if (isLegacy) {
|
||||
return value;
|
||||
|
@ -1139,6 +1146,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
Object.assign(globalThis, {
|
||||
loadNote,
|
||||
reloadNote,
|
||||
reloadNoteIfEmpty,
|
||||
saveSession,
|
||||
setFields,
|
||||
setCollapsed,
|
||||
|
|
Loading…
Reference in a new issue