From: Olaf Wintermann Date: Mon, 8 Jun 2026 18:53:05 +0000 (+0200) Subject: save notes when another notebook is selected X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=9c8adb6d129cd2fe2d999cc87bab12d1367e62dc;p=note.git save notes when another notebook is selected --- diff --git a/application/src/note.rs b/application/src/note.rs index 118820f..6f6e598 100644 --- a/application/src/note.rs +++ b/application/src/note.rs @@ -121,7 +121,12 @@ impl Note { } } - pub fn save(&self, collection_id: i32, backend: &BackendHandle) { + #[action] + pub fn save(&mut self, _event: &ActionEvent) { + self.save_note(); + } + + pub fn save_note(&self) { let Some(doc) = self.doc.get_doc() else { return; }; @@ -139,7 +144,7 @@ impl Note { let note = entity::note::ActiveModel { note_id: note_id.clone(), - collection_id: Set(collection_id), + collection_id: Set(self.collection_id), kind: Set(self.kind.clone()), title: Set(title), lastmodified: Set(Utc::now().into()), @@ -153,7 +158,7 @@ impl Note { }; let proxy = doc.doc_proxy(); - backend.save_note(note, Some(notecontent), |result|{ + self.backend.save_note(note, Some(notecontent), |result|{ proxy.call_mainthread(move |_doc, note|{ match result { Ok((note_id, content_id)) => { diff --git a/application/src/notebook.rs b/application/src/notebook.rs index 66f4347..b198fd2 100644 --- a/application/src/notebook.rs +++ b/application/src/notebook.rs @@ -56,10 +56,8 @@ impl Notebook { if let Some(mut doc) = self.doc_ref.get_doc() { // save the note let note_proxy = current.doc_proxy(); - let backend = self.backend.as_ref().clone(); - let collection_id = self.collection_id; note_proxy.call_mainthread(move |_doc, note|{ - note.save(collection_id, &backend); + note.save_note(); }); // detach the note diff --git a/application/src/window.rs b/application/src/window.rs index c3b968d..0d2aa50 100644 --- a/application/src/window.rs +++ b/application/src/window.rs @@ -202,6 +202,7 @@ pub fn create_window(app: &App, ctx: &AppContext) -> UiObject