]> uap-core.de Git - note.git/commitdiff
fix crash + correctly load attachments when creating the note view model main
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 27 Aug 2026 18:00:08 +0000 (20:00 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 27 Aug 2026 18:00:08 +0000 (20:00 +0200)
application/note/src/note.rs
ui-rs/src/ui/button.rs
ui/common/args.c

index 978ab2805d36fdb27761caa3cb0671adfd4921b6..900cc17dfdc2dfd66ece7f4222a5f4eb8e7ca28c 100644 (file)
@@ -134,6 +134,7 @@ impl Note {
             } else {
                 n.init_from_model(model);
                 n.load_content();
+                n.load_attachments();
             }
             // make sure we receive an event, when this note is attached or detached
             d.ctx.on_attachment_status_change_action("attachment_status_changed");
@@ -278,11 +279,16 @@ impl Note {
 
         let proxy = doc.doc_proxy();
         self.backend.get_note_attachments(note_id, move|result|{
-            proxy.call_mainthread(move |_doc, note|{
+            proxy.call_mainthread(move |doc, note|{
                 match result {
                     Ok(attachments) => {
                         note.attachments.data_mut().clear();
-                        note.attachments.data_mut().extend(attachments);
+                        if attachments.len() > 0 {
+                            note.attachments.data_mut().extend(attachments);
+                            doc.ctx.set_state(AppStates::NoteHasAttachments);
+                        } else {
+                            doc.ctx.unset_state(AppStates::NoteHasAttachments);
+                        }
                         note.attachments.update();
                     },
                     Err(e) => {
@@ -367,7 +373,6 @@ impl Note {
         println!("note changed by {}", _from);
 
         self.load_content();
-        self.load_attachments();
     }
 
     /// Event before the text is changed: detect if the change affects the title
index 5338f3fa833b0ad6d91d0048723065a7fa243846..5373595cb17ea3e3db1572dddcc6e49e6a573ece 100644 (file)
@@ -36,7 +36,6 @@ use crate::ui::{event, toolkit, EventWrapper};
 use crate::ui::ffi::*;
 use crate::ui::widget::*;
 
-
 #[macro_export]
 macro_rules! button {
     ($parent:expr, $($tt:tt)*) => {
index 822a7c9694cba36b3012ac03bd36b422ac1c0a96..8053d82d58f99c3a1ad6fa7db33376c83ad17346 100644 (file)
@@ -641,7 +641,7 @@ void ui_container_args_free(UiContainerArgs *args) {
 
 UiFrameArgs* ui_frame_args_new(void) {
     UiFrameArgs *args = malloc(sizeof(UiFrameArgs));
-    memset(args, 0, sizeof(UiContainerArgs));
+    memset(args, 0, sizeof(UiFrameArgs));
     return args;
 }