From a6644307dd80408d6a3e47f407dc8cc42ef05ba4 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Mon, 22 Jun 2026 20:32:19 +0200 Subject: [PATCH] fix inconsistent note title, when completely deleting an existing title --- application/src/note.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/application/src/note.rs b/application/src/note.rs index 225011d..de2a512 100644 --- a/application/src/note.rs +++ b/application/src/note.rs @@ -192,25 +192,27 @@ impl Note { } pub fn update_title(&mut self, s: &str, notify: bool) { - match generate_title(s) { + let title = match generate_title(s) { Some(result) => { let title = result.0; self.title_start = result.1 as i32; self.title_end = result.1 as i32 + title.len() as i32; - - if notify { - let update = NoteTitleUpdate { - collection_id: self.collection_id, - note_id: self.id.clone(), - title: title.to_string(), - }; - _ = self.backend.as_ref().send_broadcast(BroadcastMessage::NoteTitleUpdate(update)); - } + title }, None => { self.title_start = -1; self.title_end = -1; + "New Note" // TODO: see NoteItem::new() } + }; + + if notify { + let update = NoteTitleUpdate { + collection_id: self.collection_id, + note_id: self.id.clone(), + title: title.to_string(), + }; + _ = self.backend.as_ref().send_broadcast(BroadcastMessage::NoteTitleUpdate(update)); } } -- 2.52.0