}
}
- #[action]
- pub fn show_trash(&mut self, _event: &ActionEvent) {
+ pub fn show_collection(&mut self, doc: UiDoc<Notebook>, nav: NavigationItem) {
let Some(mut obj) = self.obj.get_object() else {
return;
};
- if let Some(trash) = &mut self.trash {
- let nav = NavigationItem { collection_id: trash.data.collection_id, ..Default::default() };
- // detach current notebook
- if let Some(current) = &self.selected_notebook {
- current.ctx.call_action("save");
- obj.ctx.detach(current);
- }
+ // detach current notebook
+ if let Some(current) = &self.selected_notebook {
+ current.ctx.call_action("save");
+ obj.ctx.detach(current);
+ }
- let notebook_doc = trash.get_doc(&self.backend);
- obj.splitview_set_visible(0, true);
- obj.ctx.attach(¬ebook_doc);
- self.selected_notebook = Some(notebook_doc);
- //e.obj.splitview_set_visible(0, !nav.note_maximized);
+ obj.splitview_set_visible(0, true);
+ obj.ctx.attach(&doc);
+ self.selected_notebook = Some(doc);
+ //e.obj.splitview_set_visible(0, !nav.note_maximized);
- self.navigation.push(nav);
- }
+ self.navigation.push(nav);
+ }
+
+ #[action]
+ pub fn show_trash(&mut self, _event: &ActionEvent) {
+ let (doc, nav) = if let Some(trash) = &mut self.trash {
+ let nav = NavigationItem { collection_id: trash.data.collection_id, ..Default::default() };
+ let notebook_doc = trash.get_doc(&self.backend);
+ (notebook_doc, nav)
+ } else {
+ return;
+ };
+ self.show_collection(doc, nav);
}
pub fn do_nav(&mut self, direction: NavDirection) -> Option<()> {
if let EventType::SubList(sl) = &e.event_type {
if let Some(nb) = sl.get_mut_from(&mut e.data.notebooks) {
let nav = NavigationItem { collection_id: nb.data.collection_id, ..Default::default() };
- // detach current notebook
- if let Some(current) = &e.data.selected_notebook {
- current.ctx.call_action("save");
- e.obj.ctx.detach(current);
- }
-
let notebook_doc = nb.get_doc(&e.data.backend);
- e.obj.splitview_set_visible(0, true);
- e.obj.ctx.attach(¬ebook_doc);
- e.data.selected_notebook = Some(notebook_doc);
- //e.obj.splitview_set_visible(0, !nav.note_maximized);
-
- e.data.navigation.push(nav);
+ e.data.show_collection(notebook_doc, nav);
}
}
}