Skip to content

Commit

Permalink
fix: dont mark unfinished shows as watched
Browse files Browse the repository at this point in the history
  • Loading branch information
lostb1t committed Jul 11, 2024
1 parent d0344b0 commit 1814226
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
17 changes: 11 additions & 6 deletions src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1333,29 +1333,34 @@ 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()
{
return true;
}
false
}


// check if we should excluse watched items for this hub
pub async fn exclude_watched(
&self,
plex_client: PlexClient,
) -> Result<bool> {
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(
Expand Down
8 changes: 1 addition & 7 deletions src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 1814226

Please sign in to comment.