fix duplicate entries to trakt

This commit is contained in:
chrisk325 2026-03-23 11:45:34 +05:30 committed by GitHub
parent 1a3c175feb
commit e5d3b037fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -462,7 +462,15 @@ export function useTraktIntegration() {
let success = false;
if (isCompleted) {
// Item is completed - add to history with original watched date
// GUARD: If this item was already synced via the scrobble path (traktSynced=true),
// skip adding it to history again. The scrobble already created the history entry.
// Calling addToWatchedMovies/Episodes here would create a duplicate history entry.
if (item.progress.traktSynced) {
logger.log(`[useTraktIntegration] Skipping syncAllProgress for already-scrobbled item: ${item.type}:${item.id}`);
return true; // Count as synced, no action needed
}
// Item is completed and not yet scrobbled - add to history with original watched date
const watchedAt = new Date(item.progress.lastUpdated);
logger.log(`[useTraktIntegration] Syncing completed item to history with date ${watchedAt.toISOString()}: ${item.type}:${item.id}`);