From 52647f8abeb1ae4e7615f8b68f032783ec011c63 Mon Sep 17 00:00:00 2001 From: chrisk325 Date: Mon, 23 Mar 2026 12:01:38 +0530 Subject: [PATCH] minor fix --- .../player/hooks/useWatchProgress.ts | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/components/player/hooks/useWatchProgress.ts b/src/components/player/hooks/useWatchProgress.ts index aeb6480d..dfd43774 100644 --- a/src/components/player/hooks/useWatchProgress.ts +++ b/src/components/player/hooks/useWatchProgress.ts @@ -171,10 +171,15 @@ export const useWatchProgress = ( await traktAutosyncRef.current.handleProgressUpdate(currentTimeRef.current, durationRef.current); // Requirement 1: Auto Episode Tracking (>= 90% completion) + // Only fires once per session via hasScrobbledRef. + // watchedService.markEpisodeAsWatched also syncs to Trakt via /sync/history. + // If the scrobble path already created the history entry (isSessionComplete=true), + // pass skipTrakt=true so we still sync MAL/Simkl but avoid a duplicate Trakt entry. const progressPercent = (currentTimeRef.current / durationRef.current) * 100; if (progressPercent >= 90 && !hasScrobbledRef.current) { hasScrobbledRef.current = true; - logger.log(`[useWatchProgress] 90% threshold reached, scrobbling to MAL...`); + const skipTrakt = traktAutosyncRef.current.isSessionComplete?.() ?? false; + logger.log(`[useWatchProgress] 90% threshold reached, syncing (skipTrakt=${skipTrakt})`); const currentImdbId = imdbIdRef.current; const currentSeason = seasonRef.current; @@ -187,19 +192,20 @@ export const useWatchProgress = ( if (type === 'series' && currentImdbId && currentSeason !== undefined && currentEpisode !== undefined) { watchedService.markEpisodeAsWatched( - currentImdbId, - id, - currentSeason, - currentEpisode, - new Date(), + currentImdbId, + id, + currentSeason, + currentEpisode, + new Date(), currentReleaseDate, undefined, currentMalId, currentDayIndex, - currentTmdbId + currentTmdbId, + skipTrakt ); } else if (type === 'movie' && currentImdbId) { - watchedService.markMovieAsWatched(currentImdbId, new Date(), currentMalId, currentTmdbId, currentTitle); + watchedService.markMovieAsWatched(currentImdbId, new Date(), currentMalId, currentTmdbId, currentTitle, skipTrakt); } } } catch (error) {