diff --git a/src/services/supabaseSyncService.ts b/src/services/supabaseSyncService.ts index b998c137a..fa0d0e70f 100644 --- a/src/services/supabaseSyncService.ts +++ b/src/services/supabaseSyncService.ts @@ -1363,7 +1363,10 @@ class SupabaseSyncService { const local = await storageService.getWatchProgress(row.content_id, type, episodeId); const remoteLastWatched = this.normalizeEpochMs(row.last_watched); - if (local && Number(local.lastUpdated || 0) >= remoteLastWatched) { + // Always pull remote data if local is a placeholder (currentTime=1,duration=1) + // to recover from corruption by watched-items sync + const isPlaceholder = local && local.currentTime === 1 && local.duration === 1; + if (local && !isPlaceholder && Number(local.lastUpdated || 0) >= remoteLastWatched) { continue; } diff --git a/src/services/watchedService.ts b/src/services/watchedService.ts index e83e0bf55..5a09cb5e4 100644 --- a/src/services/watchedService.ts +++ b/src/services/watchedService.ts @@ -765,6 +765,12 @@ class WatchedService { ): Promise { try { if (watched) { + // If existing progress has real playback data, don't overwrite with placeholder + const existing = await storageService.getWatchProgress(id, type, episodeId); + if (existing && existing.currentTime > 1 && existing.duration > 1) { + return; + } + // Create a "completed" progress entry (100% watched) const progress = { currentTime: 1, // Minimal values to indicate completion @@ -775,7 +781,8 @@ class WatchedService { }; await storageService.setWatchProgress(id, type, progress, episodeId, { forceWrite: true, - forceNotify: true + forceNotify: true, + preserveTimestamp: true, }); // Also set the legacy watched flag for movies