fix note changes triggering a queue rebuild
This commit is contained in:
parent
df600c094a
commit
1479957538
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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 {
|
||||
|
@ -21,8 +21,8 @@ impl From<OpChanges> 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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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))
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user