diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/watchprogress/WatchProgressRepository.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/watchprogress/WatchProgressRepository.kt index 23991057..ebdb27d5 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/watchprogress/WatchProgressRepository.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/watchprogress/WatchProgressRepository.kt @@ -382,8 +382,10 @@ object WatchProgressRepository { ContinueWatchingPreferencesRepository.removeDismissedNextUpKeysForContent(entry.parentMetaId) } + val useTraktProgress = shouldUseTraktProgress() + entriesByVideoId[session.videoId] = entry - if (shouldUseTraktProgress()) { + if (useTraktProgress) { TraktProgressRepository.applyOptimisticProgress(entry) } publish() @@ -392,7 +394,9 @@ object WatchProgressRepository { resolveRemoteMetadata() } pushScrobbleToServer(entry) - WatchingActions.onProgressEntryUpdated(entry) + if (shouldCascadeCompletedProgressToWatchedHistory(entry, useTraktProgress)) { + WatchingActions.onProgressEntryUpdated(entry) + } } private fun pushScrobbleToServer(entry: WatchProgressEntry) { diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/watchprogress/WatchProgressRules.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/watchprogress/WatchProgressRules.kt index 302beece..bd002706 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/watchprogress/WatchProgressRules.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/watchprogress/WatchProgressRules.kt @@ -99,6 +99,11 @@ internal fun WatchProgressEntry.shouldUseAsCompletedSeedForContinueWatching(): B return explicitPercent >= WatchProgressTraktPlaybackNextUpSeedPercentThreshold } +internal fun shouldCascadeCompletedProgressToWatchedHistory( + entry: WatchProgressEntry, + isUsingTraktProgress: Boolean, +): Boolean = !isUsingTraktProgress && entry.normalizedCompletion().isCompleted + internal fun String?.isSeriesTypeForContinueWatching(): Boolean = equals("series", ignoreCase = true) || equals("tv", ignoreCase = true) diff --git a/composeApp/src/commonTest/kotlin/com/nuvio/app/features/watchprogress/WatchProgressRulesTest.kt b/composeApp/src/commonTest/kotlin/com/nuvio/app/features/watchprogress/WatchProgressRulesTest.kt index bed674ef..b6112ba8 100644 --- a/composeApp/src/commonTest/kotlin/com/nuvio/app/features/watchprogress/WatchProgressRulesTest.kt +++ b/composeApp/src/commonTest/kotlin/com/nuvio/app/features/watchprogress/WatchProgressRulesTest.kt @@ -173,6 +173,34 @@ class WatchProgressRulesTest { assertFalse(history.shouldTreatAsInProgressForContinueWatching()) } + @Test + fun `completed progress does not cascade to watched history while Trakt progress is active`() { + val completed = entry( + videoId = "movie-complete", + isCompleted = true, + ) + val inProgress = completed.copy(isCompleted = false) + + assertFalse( + shouldCascadeCompletedProgressToWatchedHistory( + entry = completed, + isUsingTraktProgress = true, + ), + ) + assertTrue( + shouldCascadeCompletedProgressToWatchedHistory( + entry = completed, + isUsingTraktProgress = false, + ), + ) + assertFalse( + shouldCascadeCompletedProgressToWatchedHistory( + entry = inProgress, + isUsingTraktProgress = false, + ), + ) + } + @Test fun `codec normalizes completed entries inferred from percent`() { val payload = WatchProgressCodec.encodeEntries( diff --git a/iosApp/Configuration/Version.xcconfig b/iosApp/Configuration/Version.xcconfig index ffa7639f..11aa4529 100644 --- a/iosApp/Configuration/Version.xcconfig +++ b/iosApp/Configuration/Version.xcconfig @@ -1,3 +1,3 @@ CURRENT_PROJECT_VERSION=62 -MARKETING_VERSION=0.1.20 +MARKETING_VERSION=0.1.0