diff --git a/src/models.rs b/src/models.rs index 3aa8395..c25a3ea 100644 --- a/src/models.rs +++ b/src/models.rs @@ -1333,12 +1333,16 @@ impl MetaData { .unwrap() .has_label("REPLEXHERO".to_string())) } - + + // view_count stays for show even when marked unwatched. pub fn is_watched(&self) -> bool { - if self.view_count.is_some() && self.view_count.unwrap_or_default() > 0 + // movie or episode + if self.leaf_count.is_none() && self.view_count.is_some() && self.view_count.unwrap_or_default() > 0 { return true; } + + // show if self.viewed_leaf_count.is_some() && self.leaf_count.unwrap_or_default() == self.viewed_leaf_count.unwrap() { @@ -1346,16 +1350,17 @@ impl MetaData { } false } - + + // check if we should excluse watched items for this hub pub async fn exclude_watched( &self, plex_client: PlexClient, ) -> Result { + let config: Config = Config::figment().extract().unwrap(); if !self.is_collection_hub() { - return Ok(false); + return Ok(config.exclude_watched); } - - let config: Config = Config::figment().extract().unwrap(); + let collection = plex_client .clone() .get_cached( diff --git a/src/routes.rs b/src/routes.rs index 2f2493c..e3bdf8e 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -548,12 +548,8 @@ pub async fn transform_hubs_home( TransformBuilder::new(plex_client, params.clone()) .with_transform(HubStyleTransform { is_home: true }) - // .with_transform(HubSectionDirectoryTransform) .with_transform(HubWatchedTransform) .with_transform(HubMixTransform) - // .with_transform(HubChildrenLimitTransform { - // limit: params.clone().count.unwrap(), - // }) .with_transform(UserStateTransform) .with_transform(HubKeyTransform) .apply_to(&mut container) @@ -611,9 +607,6 @@ pub async fn get_hubs_sections( .with_transform(HubWatchedTransform) .with_transform(UserStateTransform) .with_transform(HubKeyTransform) - //.with_transform(MediaContainerScriptingTransform) - // .with_filter(CollectionHubPermissionFilter) - // .with_filter(WatchedFilter) .apply_to(&mut container) .await; // dbg!(container.media_container.count); @@ -733,6 +726,7 @@ pub async fn default_transform( TransformBuilder::new(plex_client, params.clone()) .with_transform(MediaStyleTransform { style: style }) .with_transform(UserStateTransform) + .with_transform(HubWatchedTransform) .apply_to(&mut container) .await;