gui: Notes forgets the open body through one helper
Three places (the open note vanishing from the tree, selecting another note, switching notebook) each stopped the body watch, dropped the stored baseline and any held incoming body, and republished the rail slot, four lines apiece. forget_open_body does it once. Same behavior; Notes' hand-rolled guard is otherwise left as is (see handoff on SyncGuarded adoption). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e9596366ec
commit
82d129f9a6
1 file changed
+15
-14
@@ -587,10 +587,7 @@ impl NotesView {
|
||||
this.content = ContentState::Empty;
|
||||
// A change held aside for it has nothing left to
|
||||
// apply to: drop the banner and the rail's count.
|
||||
this._watch_task = None;
|
||||
this.stored_body = None;
|
||||
this.incoming_body = None;
|
||||
this.publish_nav_slot(cx);
|
||||
this.forget_open_body(cx);
|
||||
}
|
||||
this.sidebar.update(cx, |s, cx| s.set_nodes(nodes, cx));
|
||||
// Restore the persisted active note now that its notebook's
|
||||
@@ -617,12 +614,7 @@ impl NotesView {
|
||||
self.selected_note = Some(id.clone());
|
||||
self.note_meta = None;
|
||||
self.content = ContentState::Loading;
|
||||
// Closing and reopening a note is the other way an arrived change gets
|
||||
// applied, so nothing about the note being left carries over.
|
||||
self._watch_task = None;
|
||||
self.stored_body = None;
|
||||
self.incoming_body = None;
|
||||
self.publish_nav_slot(cx);
|
||||
self.forget_open_body(cx);
|
||||
self.reset_typst_preview(cx);
|
||||
// A fresh note's headings occupy different indices than the last
|
||||
// one's — reset rather than let a stale `scroll_to_top_of_item`
|
||||
@@ -802,6 +794,18 @@ impl NotesView {
|
||||
}));
|
||||
}
|
||||
|
||||
/// Stop watching the open note's body and drop what was known about it —
|
||||
/// the stored baseline and any change held aside — when the open note
|
||||
/// goes away or is swapped for another. Closing and reopening a note is
|
||||
/// the other way an arrived change gets applied, so none of it carries
|
||||
/// over.
|
||||
fn forget_open_body(&mut self, cx: &mut Context<Self>) {
|
||||
self._watch_task = None;
|
||||
self.stored_body = None;
|
||||
self.incoming_body = None;
|
||||
self.publish_nav_slot(cx);
|
||||
}
|
||||
|
||||
/// Mirror the pending-incoming state into the navigation rail, so a
|
||||
/// decision waiting on the user is visible from wherever they are.
|
||||
fn publish_nav_slot(&self, cx: &mut Context<Self>) {
|
||||
@@ -1486,10 +1490,7 @@ impl NotesView {
|
||||
self.selected_note = None;
|
||||
self.note_meta = None;
|
||||
self.content = ContentState::Empty;
|
||||
self._watch_task = None;
|
||||
self.stored_body = None;
|
||||
self.incoming_body = None;
|
||||
self.publish_nav_slot(cx);
|
||||
self.forget_open_body(cx);
|
||||
self.save_active_notebook(id, cx);
|
||||
self.reload_tree(cx);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user