diff --git a/qt/aqt/browser/browser.py b/qt/aqt/browser/browser.py index 194c60def..e2c230105 100644 --- a/qt/aqt/browser/browser.py +++ b/qt/aqt/browser/browser.py @@ -116,7 +116,7 @@ class Browser(QMainWindow): focused = current_window() == self self.table.op_executed(changes, handler, focused) self.sidebar.op_executed(changes, handler, focused) - if changes.editor: + if changes.note_text: if handler is not self.editor: # fixme: this will leave the splitter shown, but with no current # note being edited diff --git a/qt/aqt/deckbrowser.py b/qt/aqt/deckbrowser.py index 35c452e6e..cb392a495 100644 --- a/qt/aqt/deckbrowser.py +++ b/qt/aqt/deckbrowser.py @@ -81,7 +81,7 @@ class DeckBrowser: def op_executed( self, changes: OpChanges, handler: Optional[object], focused: bool ) -> bool: - if changes.reviewer and handler is not self: + if changes.study_queues and handler is not self: self._refresh_needed = True if focused: diff --git a/qt/aqt/editcurrent.py b/qt/aqt/editcurrent.py index 209623e37..fa934f305 100644 --- a/qt/aqt/editcurrent.py +++ b/qt/aqt/editcurrent.py @@ -34,7 +34,7 @@ class EditCurrent(QDialog): def on_operation_did_execute( self, changes: OpChanges, handler: Optional[object] ) -> None: - if changes.editor and handler is not self.editor: + if changes.note_text and handler is not self.editor: # reload note note = self.editor.note try: diff --git a/qt/aqt/overview.py b/qt/aqt/overview.py index 19dfd1f9b..af1131834 100644 --- a/qt/aqt/overview.py +++ b/qt/aqt/overview.py @@ -74,7 +74,7 @@ class Overview: def op_executed( self, changes: OpChanges, handler: Optional[object], focused: bool ) -> bool: - if changes.reviewer: + if changes.study_queues: self._refresh_needed = True if focused: diff --git a/qt/aqt/reviewer.py b/qt/aqt/reviewer.py index 40c614f19..1b76a3991 100644 --- a/qt/aqt/reviewer.py +++ b/qt/aqt/reviewer.py @@ -169,9 +169,9 @@ class Reviewer: self, changes: OpChanges, handler: Optional[object], focused: bool ) -> bool: if handler is not self: - if changes.reviewer: + if changes.study_queues: self._refresh_needed = RefreshNeeded.QUEUES - elif changes.editor: + elif changes.note_text: self._refresh_needed = RefreshNeeded.NOTE_TEXT if focused and self._refresh_needed: diff --git a/rslib/backend.proto b/rslib/backend.proto index 33cf89c48..e15ac9cc3 100644 --- a/rslib/backend.proto +++ b/rslib/backend.proto @@ -1578,8 +1578,10 @@ message OpChanges { bool browser_table = 7; bool browser_sidebar = 8; - bool editor = 9; - bool reviewer = 10; + // editor and displayed card in review screen + bool note_text = 9; + // whether to call .reset() and getCard() + bool study_queues = 10; } message UndoStatus { diff --git a/rslib/src/backend/ops.rs b/rslib/src/backend/ops.rs index 0db69b92f..bdefe629d 100644 --- a/rslib/src/backend/ops.rs +++ b/rslib/src/backend/ops.rs @@ -21,8 +21,8 @@ impl From for pb::OpChanges { mtime: c.changes.mtime, browser_table: c.requires_browser_table_redraw(), browser_sidebar: c.requires_browser_sidebar_redraw(), - editor: c.requires_editor_redraw(), - reviewer: c.requires_reviewer_redraw(), + note_text: c.requires_note_text_redraw(), + study_queues: c.requires_study_queue_rebuild(), } } } diff --git a/rslib/src/ops.rs b/rslib/src/ops.rs index 97812a5fb..95ebee7ae 100644 --- a/rslib/src/ops.rs +++ b/rslib/src/ops.rs @@ -149,29 +149,13 @@ impl OpChanges { c.tag || c.deck || c.notetype || c.config } - pub fn requires_editor_redraw(&self) -> bool { + pub fn requires_note_text_redraw(&self) -> bool { let c = &self.changes; c.note || c.notetype } - pub fn requires_reviewer_redraw(&self) -> bool { + pub fn requires_study_queue_rebuild(&self) -> bool { let c = &self.changes; - c.card - || (c.deck && self.op != Op::ExpandCollapse) - || (c.config && matches!(self.op, Op::SetCurrentDeck | Op::UpdatePreferences)) - || c.deck_config - || c.note - || c.notetype - } - - /// Internal; allows us to avoid rebuilding queues after AnswerCard, - /// and a few other ops as an optimization. - pub(crate) fn requires_study_queue_rebuild(&self) -> bool { - let c = &self.changes; - if self.op == Op::AnswerCard { - return false; - } - c.card || (c.deck && self.op != Op::ExpandCollapse) || (c.config && matches!(self.op, Op::SetCurrentDeck | Op::UpdatePreferences)) diff --git a/rslib/src/scheduler/queue/mod.rs b/rslib/src/scheduler/queue/mod.rs index 50017273d..64c5cac00 100644 --- a/rslib/src/scheduler/queue/mod.rs +++ b/rslib/src/scheduler/queue/mod.rs @@ -166,7 +166,7 @@ impl Collection { } pub(crate) fn maybe_clear_study_queues_after_op(&mut self, op: &OpChanges) { - if op.requires_study_queue_rebuild() { + if op.op != Op::AnswerCard && op.requires_study_queue_rebuild() { self.state.card_queues = None; } }