From 69df218b404d4e63a5b52a427bb2c75a0798d652 Mon Sep 17 00:00:00 2001 From: tapframe <85391825+tapframe@users.noreply.github.com> Date: Sun, 15 Mar 2026 09:39:59 +0530 Subject: [PATCH] fix: local cw removal not taking effect on cloud --- .../tv/core/sync/WatchProgressSyncService.kt | 1 - .../repository/WatchProgressRepositoryImpl.kt | 23 +++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/nuvio/tv/core/sync/WatchProgressSyncService.kt b/app/src/main/java/com/nuvio/tv/core/sync/WatchProgressSyncService.kt index c6057eb9..f1c69a83 100644 --- a/app/src/main/java/com/nuvio/tv/core/sync/WatchProgressSyncService.kt +++ b/app/src/main/java/com/nuvio/tv/core/sync/WatchProgressSyncService.kt @@ -50,7 +50,6 @@ class WatchProgressSyncService @Inject constructor( suspend fun deleteFromRemote(keys: Collection): Result = withContext(Dispatchers.IO) { try { if (!shouldUseSupabaseWatchProgressSync()) { - Log.d(TAG, "Using Trakt watch progress, skipping watch progress delete") return@withContext Result.success(Unit) } diff --git a/app/src/main/java/com/nuvio/tv/data/repository/WatchProgressRepositoryImpl.kt b/app/src/main/java/com/nuvio/tv/data/repository/WatchProgressRepositoryImpl.kt index 5397e9f7..0df9ca83 100644 --- a/app/src/main/java/com/nuvio/tv/data/repository/WatchProgressRepositoryImpl.kt +++ b/app/src/main/java/com/nuvio/tv/data/repository/WatchProgressRepositoryImpl.kt @@ -425,10 +425,11 @@ class WatchProgressRepositoryImpl @Inject constructor( override suspend fun removeProgress(contentId: String, season: Int?, episode: Int?) { val useTraktProgress = shouldUseTraktProgress() val hasEffectiveTraktConnection = hasEffectiveTraktConnection() - Log.d( - TAG, - "removeProgress called contentId=$contentId season=$season episode=$episode useTraktProgress=$useTraktProgress hasEffectiveTraktConnection=$hasEffectiveTraktConnection" - ) + val remoteDeleteKeys = if (!useTraktProgress) { + resolveRemoteDeleteKeys(contentId, season, episode) + } else { + emptyList() + } if (hasEffectiveTraktConnection) { traktProgressService.applyOptimisticRemoval(contentId, season, episode) traktProgressService.removeProgress(contentId, season, episode) @@ -437,7 +438,6 @@ class WatchProgressRepositoryImpl @Inject constructor( if (useTraktProgress) { return } - val remoteDeleteKeys = resolveRemoteDeleteKeys(contentId, season, episode) if (authManager.isAuthenticated && remoteDeleteKeys.isNotEmpty()) { watchProgressSyncService.deleteFromRemote(remoteDeleteKeys) .onFailure { error -> @@ -449,6 +449,11 @@ class WatchProgressRepositoryImpl @Inject constructor( override suspend fun removeFromHistory(contentId: String, videoId: String?, season: Int?, episode: Int?) { val useTraktProgress = shouldUseTraktProgress() + val remoteDeleteKeys = if (!useTraktProgress) { + resolveRemoteDeleteKeys(contentId, season, episode) + } else { + emptyList() + } if (hasEffectiveTraktConnection()) { traktProgressService.removeFromHistory(contentId, videoId, season, episode) } @@ -457,7 +462,6 @@ class WatchProgressRepositoryImpl @Inject constructor( if (useTraktProgress) { return } - val remoteDeleteKeys = resolveRemoteDeleteKeys(contentId, season, episode) if (authManager.isAuthenticated && remoteDeleteKeys.isNotEmpty()) { watchProgressSyncService.deleteFromRemote(remoteDeleteKeys) .onFailure { error -> @@ -564,21 +568,22 @@ class WatchProgressRepositoryImpl @Inject constructor( season: Int?, episode: Int? ): List { + val rawEntries = watchProgressPreferences.getAllRawEntries() val keys = if (season != null && episode != null) { listOf("${contentId}_s${season}e${episode}", contentId) } else { - val matchingLocalKeys = watchProgressPreferences - .getAllRawEntries() + val matchingLocalKeys = rawEntries .keys .filter { key -> key == contentId || key.startsWith("${contentId}_") } matchingLocalKeys + contentId } - return keys + val resolvedKeys = keys .map { it.trim() } .filter { it.isNotEmpty() } .distinct() + return resolvedKeys } }