| 1 | use std::sync::Arc; |
| 2 | |
| 3 | use topcoat::{ |
| 4 | Result, |
| 5 | context::{Cx, app_context}, |
| 6 | router::page, |
| 7 | view::{Child, View}, |
| 8 | }; |
| 9 | |
| 10 | use crate::app::pane::{self, ListSpec, Mobile}; |
| 11 | use crate::i18n::{self, Msg, t}; |
| 12 | use crate::store::{ListFilter, Store}; |
| 13 | |
| 14 | |
| 15 | #[page] |
| 16 | async fn unfiled(cx: &Cx) -> Result<impl View> { |
| 17 | let store = app_context::<Arc<Store>>(cx); |
| 18 | let notebooks = store.list_notebooks().await.map_err(topcoat::Error::from_anyhow)?; |
| 19 | let page = pane::load_page(cx, store, ListFilter::Unfiled) |
| 20 | .await |
| 21 | .map_err(topcoat::Error::from_anyhow)?; |
| 22 | let lang = i18n::lang(cx); |
| 23 | let spec = ListSpec { |
| 24 | title: t(lang, Msg::Unfiled).to_owned(), |
| 25 | heading: true, |
| 26 | count: page.total, |
| 27 | notebook_id: String::new(), |
| 28 | groups: pane::groups(lang, &page.notes, ¬ebooks, &page.previews, None, false), |
| 29 | empty: t(lang, Msg::EmptyUnfiled), |
| 30 | more: page.more, |
| 31 | }; |
| 32 | let list = pane::list_pane(cx, lang, spec, Child::new(())); |
| 33 | Ok(pane::split( |
| 34 | cx, |
| 35 | Mobile::List, |
| 36 | Child::new(list), |
| 37 | Child::new(pane::empty_detail(cx, lang)), |
| 38 | )) |
| 39 | } |