self.update_title(content.content.as_str(), false);
}
+ pub fn load_content(&mut self, doc: &UiDoc<Note>) {
+ let proxy = doc.doc_proxy();
+ self.backend.get_note_content(self.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);
+ }
+ }
+ });
+ });
+ }
+
pub fn update_title(&mut self, s: &str, notify: bool) {
match generate_title(s) {
Some(result) => {
} else {
// 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(¬e.data);
-
- let proxy = d.doc_proxy();
- self.backend.get_note_content(note.data.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);
- }
- }
- });
- });
+ n.load_content(d);
})
};
+ note.model = Some(doc.clone());
if let Some(mut nb) = self.doc_ref.get_doc() {
nb.ctx.attach(&doc);