aboutsummaryrefslogtreecommitdiff
path: root/server/src/routes/ui
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/routes/ui')
-rw-r--r--server/src/routes/ui/sort.rs24
1 files changed, 22 insertions, 2 deletions
diff --git a/server/src/routes/ui/sort.rs b/server/src/routes/ui/sort.rs
index b140de8..9428694 100644
--- a/server/src/routes/ui/sort.rs
+++ b/server/src/routes/ui/sort.rs
@@ -1,4 +1,8 @@
-use jellycommon::{helpers::SortAnyway, user::NodeUserData, NodeKind, NodePublic, Rating};
+use jellycommon::{
+ helpers::SortAnyway,
+ user::{NodeUserData, WatchedState},
+ NodeKind, NodePublic, Rating,
+};
use rocket::{
http::uri::fmt::{Query, UriDisplay},
FromForm, FromFormField, UriDisplayQuery,
@@ -23,6 +27,9 @@ form_enum!(
enum FilterProperty {
FederationLocal = "fed_local",
FederationRemote = "fed_remote",
+ Watched = "watched",
+ Unwatched = "unwatched",
+ WatchProgress = "watch_progress",
KindMovie = "kind_movie",
KindVideo = "kind_video",
KindCollection = "kind_collection",
@@ -92,6 +99,14 @@ impl FilterProperty {
"By Federation",
&[(FederationLocal, "Local"), (FederationRemote, "Remote")],
),
+ (
+ "By Watched",
+ &[
+ (Watched, "Watched"),
+ (Unwatched, "Unwatched"),
+ (WatchProgress, "Partially Watched"),
+ ],
+ ),
]
};
}
@@ -113,7 +128,7 @@ pub fn filter_and_sort_nodes(
f: &NodeFilterSort,
nodes: &mut Vec<(String, NodePublic, NodeUserData)>,
) {
- nodes.retain(|(_id, node, _udata)| {
+ nodes.retain(|(_id, node, udata)| {
let mut o = true;
if let Some(prop) = &f.filter_kind {
for p in FilterProperty::ALL {
@@ -131,6 +146,11 @@ pub fn filter_and_sort_nodes(
FilterProperty::KindSeries => node.kind == NodeKind::Series,
FilterProperty::KindSeason => node.kind == NodeKind::Season,
FilterProperty::KindEpisode => node.kind == NodeKind::Episode,
+ FilterProperty::Watched => udata.watched == WatchedState::Watched,
+ FilterProperty::Unwatched => udata.watched == WatchedState::None,
+ FilterProperty::WatchProgress => {
+ matches!(udata.watched, WatchedState::Progress(_))
+ }
}
}
}