diff options
author | metamuffin <metamuffin@disroot.org> | 2023-12-16 01:08:15 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-12-16 01:08:15 +0100 |
commit | af99c406af8ee47bee38708cf23e86af826e41ba (patch) | |
tree | 23498a36f813454c2edea46906f812d929ba792e /server/src/routes/ui/browser.rs | |
parent | 21b58037c69798e922c5512ea5380943781558ff (diff) | |
download | jellything-af99c406af8ee47bee38708cf23e86af826e41ba.tar jellything-af99c406af8ee47bee38708cf23e86af826e41ba.tar.bz2 jellything-af99c406af8ee47bee38708cf23e86af826e41ba.tar.zst |
watch progress and some draft ui
Diffstat (limited to 'server/src/routes/ui/browser.rs')
-rw-r--r-- | server/src/routes/ui/browser.rs | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/server/src/routes/ui/browser.rs b/server/src/routes/ui/browser.rs index d2c24bc..509f242 100644 --- a/server/src/routes/ui/browser.rs +++ b/server/src/routes/ui/browser.rs @@ -12,7 +12,7 @@ use super::{ }; use crate::{database::Database, uri}; use anyhow::Context; -use jellycommon::NodePublic; +use jellycommon::{user::NodeUserData, NodePublic}; use rocket::{get, State}; /// This function is a stub and only useful for use in the uri! macro. @@ -21,7 +21,7 @@ pub fn r_all_items() {} #[get("/items?<page>&<filter..>")] pub fn r_all_items_filter( - _sess: Session, + sess: Session, db: &State<Database>, page: Option<usize>, filter: NodeFilterSort, @@ -29,11 +29,18 @@ pub fn r_all_items_filter( let mut items = db .node .iter() - .map(|e| e.context("listing")) + .map(|e| { + let (i, n) = e.context("listing")?; + let u = db + .user_node + .get(&(sess.user.name.clone(), i.clone()))? + .unwrap_or_default(); + Ok((i, n, u)) + }) .collect::<anyhow::Result<Vec<_>>>()? .into_iter() - .map(|(k, n)| (k, n.public)) - .collect::<Vec<(String, NodePublic)>>(); + .map(|(k, n, u)| (k, n.public, u)) + .collect::<Vec<(String, NodePublic, NodeUserData)>>(); filter_and_sort_nodes(&filter, &mut items); @@ -50,8 +57,8 @@ pub fn r_all_items_filter( .page.dir { h1 { "All Items" } @NodeFilterSortForm { f: &filter } - ul.children { @for (id, node) in &items[from..to] { - li {@NodeCard { id, node: &node }} + ul.children { @for (id, node, udata) in &items[from..to] { + li {@NodeCard { id, node, udata }} }} p.pagecontrols { span.current { "Page " @{page + 1} " of " @max_page " " } |