} 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");
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) => {
println!("note changed by {}", _from);
self.load_content();
- self.load_attachments();
}
/// Event before the text is changed: detect if the change affects the title
UiFrameArgs* ui_frame_args_new(void) {
UiFrameArgs *args = malloc(sizeof(UiFrameArgs));
- memset(args, 0, sizeof(UiContainerArgs));
+ memset(args, 0, sizeof(UiFrameArgs));
return args;
}