diff options
author | metamuffin <metamuffin@disroot.org> | 2023-12-25 21:06:47 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-12-25 21:06:47 +0100 |
commit | 2ff2d07b5ed265d0f4ce095002484fe771e51dae (patch) | |
tree | c1ec7370f0df772a5fafd2bf33b7481036c06f65 /server/src/routes/ui | |
parent | e2c62c34b4c2983b8ceef034347bc62b28a88122 (diff) | |
download | jellything-2ff2d07b5ed265d0f4ce095002484fe771e51dae.tar jellything-2ff2d07b5ed265d0f4ce095002484fe771e51dae.tar.bz2 jellything-2ff2d07b5ed265d0f4ce095002484fe771e51dae.tar.zst |
watchlist and some small fixes
Diffstat (limited to 'server/src/routes/ui')
-rw-r--r-- | server/src/routes/ui/home.rs | 12 | ||||
-rw-r--r-- | server/src/routes/ui/node.rs | 30 |
2 files changed, 31 insertions, 11 deletions
diff --git a/server/src/routes/ui/home.rs b/server/src/routes/ui/home.rs index ed9f7c1..6a3b9a4 100644 --- a/server/src/routes/ui/home.rs +++ b/server/src/routes/ui/home.rs @@ -73,6 +73,12 @@ pub fn r_home(sess: Session, db: &State<Database>) -> MyResult<DynLayoutPage> { .filter(|(_, _, u)| matches!(u.watched, WatchedState::Progress(_))) .map(|k| k.to_owned()) .collect::<Vec<_>>(); + + let watchlist = items + .iter() + .filter(|(_, _, u)| matches!(u.watched, WatchedState::Pending)) + .map(|k| k.to_owned()) + .collect::<Vec<_>>(); Ok(LayoutPage { title: "Home".to_string(), @@ -87,6 +93,12 @@ pub fn r_home(sess: Session, db: &State<Database>) -> MyResult<DynLayoutPage> { li { @NodeCard { id, node, udata } } }}} } + @if !watchlist.is_empty() { + h2 { "Watchlist" } + .homelist { ul {@for (id, node, udata) in &watchlist { + li { @NodeCard { id, node, udata } } + }}} + } h2 { "Latest Releases" } .homelist { ul {@for (id, node, udata) in &latest { li { @NodeCard { id, node, udata } } diff --git a/server/src/routes/ui/node.rs b/server/src/routes/ui/node.rs index 7f80ea2..795effa 100644 --- a/server/src/routes/ui/node.rs +++ b/server/src/routes/ui/node.rs @@ -12,7 +12,7 @@ use crate::{ database::Database, routes::{ api::AcceptJson, - progress::rocket_uri_macro_r_player_watched, + progress::{rocket_uri_macro_r_player_watched, UrlWatchedState}, ui::{ account::session::Session, assets::AssetRole, @@ -114,17 +114,24 @@ markup::define! { h1 { @node.title } @if node.media.is_some() { a.play[href=&uri!(r_player(id, PlayerConfig::default()))] { "Watch now" }} @if !matches!(node.kind.unwrap_or_default(), NodeKind::Collection | NodeKind::Channel) { - @match udata.watched { - WatchedState::None | - WatchedState::Progress(_) => { - form.mark_watched[method="POST", action=uri!(r_player_watched(id, true))] { - input[type="submit", value="Mark Watched"]; - } + @if matches!(udata.watched, WatchedState::None | WatchedState::Pending | WatchedState::Progress(_)) { + form.mark_watched[method="POST", action=uri!(r_player_watched(id, UrlWatchedState::Watched))] { + input[type="submit", value="Mark Watched"]; } - WatchedState::Watched => { - form.mark_unwatched[method="POST", action=uri!(r_player_watched(id, false))] { - input[type="submit", value="Mark Unwatched"]; - } + } + @if matches!(udata.watched, WatchedState::Watched) { + form.mark_unwatched[method="POST", action=uri!(r_player_watched(id, UrlWatchedState::None))] { + input[type="submit", value="Mark Unwatched"]; + } + } + @if matches!(udata.watched, WatchedState::None) { + form.mark_unwatched[method="POST", action=uri!(r_player_watched(id, UrlWatchedState::Pending))] { + input[type="submit", value="Add to Watchlist"]; + } + } + @if matches!(udata.watched, WatchedState::Pending) { + form.mark_unwatched[method="POST", action=uri!(r_player_watched(id, UrlWatchedState::None))] { + input[type="submit", value="Remove from Watchlist"]; } } } @@ -199,6 +206,7 @@ markup::define! { } @match udata.watched { WatchedState::None => {} + WatchedState::Pending => { p.pending { "Watchlisted" } } WatchedState::Progress(x) => { p.progress { "Watched up to " @format_duration(x) } } WatchedState::Watched => { p.watched { "Watched" } } } |