Skip to content

Commit 1814226

Browse files
committed
fix: dont mark unfinished shows as watched
1 parent d0344b0 commit 1814226

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

src/models.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -1333,29 +1333,34 @@ impl MetaData {
13331333
.unwrap()
13341334
.has_label("REPLEXHERO".to_string()))
13351335
}
1336-
1336+
1337+
// view_count stays for show even when marked unwatched.
13371338
pub fn is_watched(&self) -> bool {
1338-
if self.view_count.is_some() && self.view_count.unwrap_or_default() > 0
1339+
// movie or episode
1340+
if self.leaf_count.is_none() && self.view_count.is_some() && self.view_count.unwrap_or_default() > 0
13391341
{
13401342
return true;
13411343
}
1344+
1345+
// show
13421346
if self.viewed_leaf_count.is_some()
13431347
&& self.leaf_count.unwrap_or_default() == self.viewed_leaf_count.unwrap()
13441348
{
13451349
return true;
13461350
}
13471351
false
13481352
}
1349-
1353+
1354+
// check if we should excluse watched items for this hub
13501355
pub async fn exclude_watched(
13511356
&self,
13521357
plex_client: PlexClient,
13531358
) -> Result<bool> {
1359+
let config: Config = Config::figment().extract().unwrap();
13541360
if !self.is_collection_hub() {
1355-
return Ok(false);
1361+
return Ok(config.exclude_watched);
13561362
}
1357-
1358-
let config: Config = Config::figment().extract().unwrap();
1363+
13591364
let collection = plex_client
13601365
.clone()
13611366
.get_cached(

src/routes.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -548,12 +548,8 @@ pub async fn transform_hubs_home(
548548

549549
TransformBuilder::new(plex_client, params.clone())
550550
.with_transform(HubStyleTransform { is_home: true })
551-
// .with_transform(HubSectionDirectoryTransform)
552551
.with_transform(HubWatchedTransform)
553552
.with_transform(HubMixTransform)
554-
// .with_transform(HubChildrenLimitTransform {
555-
// limit: params.clone().count.unwrap(),
556-
// })
557553
.with_transform(UserStateTransform)
558554
.with_transform(HubKeyTransform)
559555
.apply_to(&mut container)
@@ -611,9 +607,6 @@ pub async fn get_hubs_sections(
611607
.with_transform(HubWatchedTransform)
612608
.with_transform(UserStateTransform)
613609
.with_transform(HubKeyTransform)
614-
//.with_transform(MediaContainerScriptingTransform)
615-
// .with_filter(CollectionHubPermissionFilter)
616-
// .with_filter(WatchedFilter)
617610
.apply_to(&mut container)
618611
.await;
619612
// dbg!(container.media_container.count);
@@ -733,6 +726,7 @@ pub async fn default_transform(
733726
TransformBuilder::new(plex_client, params.clone())
734727
.with_transform(MediaStyleTransform { style: style })
735728
.with_transform(UserStateTransform)
729+
.with_transform(HubWatchedTransform)
736730
.apply_to(&mut container)
737731
.await;
738732

0 commit comments

Comments
 (0)