aboutsummaryrefslogtreecommitdiff
path: root/server/src/routes/ui/browser.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/routes/ui/browser.rs')
-rw-r--r--server/src/routes/ui/browser.rs30
1 files changed, 5 insertions, 25 deletions
diff --git a/server/src/routes/ui/browser.rs b/server/src/routes/ui/browser.rs
index 9a5fb6c..a15dc27 100644
--- a/server/src/routes/ui/browser.rs
+++ b/server/src/routes/ui/browser.rs
@@ -10,8 +10,7 @@ use super::{
node::NodeCard,
sort::{filter_and_sort_nodes, NodeFilterSort, NodeFilterSortForm, SortOrder, SortProperty},
};
-use crate::{database::DataAcid, uri};
-use jellybase::database::{redb::ReadableTable, T_NODE, T_USER_NODE};
+use crate::{database::Database, uri};
use rocket::{get, State};
/// This function is a stub and only useful for use in the uri! macro.
@@ -21,30 +20,11 @@ pub fn r_all_items() {}
#[get("/items?<page>&<filter..>")]
pub fn r_all_items_filter(
sess: Session,
- db: &State<DataAcid>,
+ db: &State<Database>,
page: Option<usize>,
filter: NodeFilterSort,
) -> Result<DynLayoutPage<'_>, MyError> {
- let mut items = {
- let txn = db.begin_read()?;
- let nodes = txn.open_table(T_NODE)?;
- let node_users = txn.open_table(T_USER_NODE)?;
- let i = nodes
- .iter()?
- .map(|a| {
- let (x, y) = a.unwrap();
- let (x, y) = (x.value().to_owned(), y.value().0);
- let z = node_users
- .get(&(sess.user.name.as_str(), x.as_str()))
- .unwrap()
- .map(|z| z.value().0)
- .unwrap_or_default();
- (x, y, z)
- })
- .collect::<Vec<_>>();
- drop(nodes);
- i
- };
+ let mut items = db.list_nodes_with_udata(sess.user.name.as_str())?;
filter_and_sort_nodes(
&filter,
@@ -65,8 +45,8 @@ pub fn r_all_items_filter(
.page.dir {
h1 { "All Items" }
@NodeFilterSortForm { f: &filter }
- ul.children { @for (id, node, udata) in &items[from..to] {
- li {@NodeCard { id, node, udata }}
+ ul.children { @for (node, udata) in &items[from..to] {
+ li {@NodeCard { node, udata }}
}}
p.pagecontrols {
span.current { "Page " @{page + 1} " of " @max_page " " }