}
}
- 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;
};
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()),
};
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)) => {
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
let nav = NavigationItem { collection_id: nb.data.collection_id, note_id: None };
// detach current notebook
if let Some(current) = &e.data.selected_notebook {
+ current.ctx.call_action("save");
e.obj.ctx.detach(current);
}