From f3e7d9492f0d11e034ad742ac03cf5329d5bb5ba Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Mon, 8 Jun 2026 20:58:59 +0200 Subject: [PATCH] only save notes when they were modified --- application/src/note.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/application/src/note.rs b/application/src/note.rs index 6f6e598..e168ec7 100644 --- a/application/src/note.rs +++ b/application/src/note.rs @@ -26,6 +26,8 @@ pub struct Note { title_start: i32, title_end: i32, + modified: bool, + #[bind("note_type")] pub note_type: UiInteger, @@ -47,6 +49,7 @@ impl Note { extract_title: false, title_start: -1, title_end: -1, + modified: false, note_type: Default::default(), text: Default::default(), @@ -126,7 +129,11 @@ impl Note { self.save_note(); } - pub fn save_note(&self) { + pub fn save_note(&mut self) { + if !self.modified { + return; + } + let Some(doc) = self.doc.get_doc() else { return; }; @@ -172,6 +179,8 @@ impl Note { } }); }); + + self.modified = false; } /// Event before the text is changed: detect if the change affects the title @@ -203,6 +212,11 @@ impl Note { #[action] pub fn note_text_changed(&mut self, event: &ActionEvent) { + if event.set { + // this event was triggered by UiText.set + return; + } + self.modified = true; if !event.set && self.extract_title { self.update_title(self.text.get().as_str(), true); } -- 2.52.0