mirror of
https://github.com/ankitects/anki.git
synced 2025-11-06 12:47:11 -05:00
Move .reload_note() calls
This commit is contained in:
parent
9b28ed87f2
commit
6248a71f2a
3 changed files with 19 additions and 32 deletions
|
|
@ -185,12 +185,6 @@ class Browser(QMainWindow):
|
||||||
focused = current_window() == self
|
focused = current_window() == self
|
||||||
self.table.op_executed(changes, handler, focused)
|
self.table.op_executed(changes, handler, focused)
|
||||||
self.sidebar.op_executed(changes, handler, focused)
|
self.sidebar.op_executed(changes, handler, focused)
|
||||||
if changes.note_text:
|
|
||||||
if handler is not self.editor:
|
|
||||||
# fixme: this will leave the splitter shown, but with no current
|
|
||||||
# note being edited
|
|
||||||
assert self.editor is not None
|
|
||||||
self.editor.reload_note()
|
|
||||||
|
|
||||||
if changes.browser_table and changes.card:
|
if changes.browser_table and changes.card:
|
||||||
self.card = self.table.get_single_selected_card()
|
self.card = self.table.get_single_selected_card()
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,6 @@ from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
|
|
||||||
import aqt.editor
|
|
||||||
from anki.collection import OpChanges
|
|
||||||
from aqt import gui_hooks
|
|
||||||
from aqt.editcurrent_legacy import *
|
from aqt.editcurrent_legacy import *
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
from aqt.utils import add_close_shortcut, restoreGeom, saveGeom, tr
|
from aqt.utils import add_close_shortcut, restoreGeom, saveGeom, tr
|
||||||
|
|
@ -34,17 +31,9 @@ class NewEditCurrent(QMainWindow):
|
||||||
self.editor.set_note(self.mw.reviewer.card.note(), focusTo=0)
|
self.editor.set_note(self.mw.reviewer.card.note(), focusTo=0)
|
||||||
restoreGeom(self, "editcurrent")
|
restoreGeom(self, "editcurrent")
|
||||||
add_close_shortcut(self)
|
add_close_shortcut(self)
|
||||||
gui_hooks.operation_did_execute.append(self.on_operation_did_execute)
|
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def on_operation_did_execute(
|
|
||||||
self, changes: OpChanges, handler: object | None
|
|
||||||
) -> None:
|
|
||||||
if changes.note_text and handler is not self.editor:
|
|
||||||
self.editor.reload_note()
|
|
||||||
|
|
||||||
def cleanup(self) -> None:
|
def cleanup(self) -> None:
|
||||||
gui_hooks.operation_did_execute.remove(self.on_operation_did_execute)
|
|
||||||
self.editor.cleanup()
|
self.editor.cleanup()
|
||||||
saveGeom(self, "editcurrent")
|
saveGeom(self, "editcurrent")
|
||||||
aqt.dialogs.markClosed("NewEditCurrent")
|
aqt.dialogs.markClosed("NewEditCurrent")
|
||||||
|
|
@ -68,5 +57,3 @@ class NewEditCurrent(QMainWindow):
|
||||||
onsuccess()
|
onsuccess()
|
||||||
|
|
||||||
self.editor.call_after_note_saved(callback)
|
self.editor.call_after_note_saved(callback)
|
||||||
|
|
||||||
onReset = on_operation_did_execute
|
|
||||||
|
|
|
||||||
|
|
@ -774,6 +774,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
initToast,
|
initToast,
|
||||||
showToast,
|
showToast,
|
||||||
} from "../image-occlusion/toast-utils.svelte";
|
} from "../image-occlusion/toast-utils.svelte";
|
||||||
|
import type { OpChanges } from "@generated/anki/collection_pb";
|
||||||
|
|
||||||
$: isIOImageLoaded = false;
|
$: isIOImageLoaded = false;
|
||||||
$: ioImageLoadedStore.set(isIOImageLoaded);
|
$: ioImageLoadedStore.set(isIOImageLoaded);
|
||||||
|
|
@ -1219,6 +1220,23 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function onOperationDidExecute(changes: Partial<OpChanges>) {
|
||||||
|
if (mode === "add" && (changes.notetype || changes.deck)) {
|
||||||
|
let homeDeckId = 0n;
|
||||||
|
if (reviewerCard) {
|
||||||
|
homeDeckId = reviewerCard.originalDeckId || reviewerCard.deckId;
|
||||||
|
}
|
||||||
|
const chooserDefaults = await defaultsForAdding({
|
||||||
|
homeDeckOfCurrentReviewCard: homeDeckId,
|
||||||
|
});
|
||||||
|
notetypeChooser.select(chooserDefaults.notetypeId);
|
||||||
|
onNotetypeChange(chooserDefaults.notetypeId, false);
|
||||||
|
}
|
||||||
|
else if (mode !== "add" && changes.noteText) {
|
||||||
|
reloadNote();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$: signalEditorState($editorState);
|
$: signalEditorState($editorState);
|
||||||
|
|
||||||
$: $editorState = getEditorState(
|
$: $editorState = getEditorState(
|
||||||
|
|
@ -1234,19 +1252,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
registerOperationHandler(async (changes) => {
|
registerOperationHandler(onOperationDidExecute);
|
||||||
if (mode === "add" && (changes.notetype || changes.deck)) {
|
|
||||||
let homeDeckId = 0n;
|
|
||||||
if (reviewerCard) {
|
|
||||||
homeDeckId = reviewerCard.originalDeckId || reviewerCard.deckId;
|
|
||||||
}
|
|
||||||
const chooserDefaults = await defaultsForAdding({
|
|
||||||
homeDeckOfCurrentReviewCard: homeDeckId,
|
|
||||||
});
|
|
||||||
notetypeChooser.select(chooserDefaults.notetypeId);
|
|
||||||
onNotetypeChange(chooserDefaults.notetypeId, false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (mode === "add") {
|
if (mode === "add") {
|
||||||
deregisterSticky = registerShortcut(toggleStickyAll, "Shift+F9");
|
deregisterSticky = registerShortcut(toggleStickyAll, "Shift+F9");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue