forge
Explore
Log in

Don't you dare go Hollow

project_note

Clone
★ 0

0 watching0 forksRust3.6 MiBc49f5e7Tahinli1 month ago2 commits

unfiled.rs39 lines, 1.2 KiBHistoryRawDownload
1use std::sync::Arc;
2
3use topcoat::{
4 Result,
5 context::{Cx, app_context},
6 router::page,
7 view::{Child, View},
8};
9
10use crate::app::pane::{self, ListSpec, Mobile};
11use crate::i18n::{self, Msg, t};
12use crate::store::{ListFilter, Store};
13
14/// GET /unfiled: notes that are not in any notebook, beside the list.
15#[page]
16async 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, &notebooks, &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}