}
}
- pub fn load_note(&self, note: &entity::note::Model) -> UiDoc<crate::note::Note> {
- // Create the new note
- let note_data = crate::note::Note::new(self.collection_id, self.backend.clone());
-
- // Create the note document object
- UiDoc::new2(note_data, |n,d| {
- // TODO: remove this when toolkit is not that buggy
- // for some reason we have to attach the doc first, before we can
- // set the text
- if let Some(mut nb) = self.doc_ref.get_doc() {
- nb.ctx.attach(&d);
- }
-
- n.init_from_model(note);
-
- let proxy = d.doc_proxy();
- self.backend.get_note_content(note.note_id, move|result|{
- proxy.call_mainthread(|doc, note|{
- match result {
- Ok(content) => {
- if let Some(content) = content {
- note.init_content(&content);
- } else {
- println!("note {}: no content", note.note_id);
- }
- },
- Err(e) => {
- println!("Cannot get note content: {}", e);
- }
- }
- });
- });
- })
- }
-
#[action]
pub fn message(&mut self, _event: &ActionEvent) {
while let Ok(msg) = self.broadcast_rx.try_recv() {