cw ordering fix

This commit is contained in:
tapframe 2026-03-09 03:22:02 +05:30
parent 837decd9bd
commit 6c06126b68
2 changed files with 12 additions and 2 deletions

View file

@ -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;
}

View file

@ -765,6 +765,12 @@ class WatchedService {
): Promise<void> {
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