]> uap-core.de Git - note.git/commitdiff
fix inconsistent note title, when completely deleting an existing title main
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Mon, 22 Jun 2026 18:32:19 +0000 (20:32 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Mon, 22 Jun 2026 18:32:19 +0000 (20:32 +0200)
application/src/note.rs

index 225011daae79609e68891a2df19bf9acb4d45927..de2a512bb188a88c3b2664811673d897d908a100 100644 (file)
@@ -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));
         }
     }