From: Olaf Wintermann Date: Mon, 22 Jun 2026 18:32:19 +0000 (+0200) Subject: fix inconsistent note title, when completely deleting an existing title X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=a6644307dd80408d6a3e47f407dc8cc42ef05ba4;p=note.git fix inconsistent note title, when completely deleting an existing title --- 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)); } }