From 9f3831e733142d5604e42569dcce2e17018dcf0f Mon Sep 17 00:00:00 2001 From: chrisk325 Date: Thu, 1 Jan 2026 01:16:18 +0530 Subject: [PATCH] fix for trakt only syncing the latest season disregarding the previous seasons --- src/hooks/useTraktIntegration.ts | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/hooks/useTraktIntegration.ts b/src/hooks/useTraktIntegration.ts index b101bba..6d143cc 100644 --- a/src/hooks/useTraktIntegration.ts +++ b/src/hooks/useTraktIntegration.ts @@ -521,9 +521,10 @@ export function useTraktIntegration() { try { // Fetch both playback progress and recently watched movies - const [traktProgress, watchedMovies] = await Promise.all([ + const [traktProgress, watchedMovies, watchedShows] = await Promise.all([ getTraktPlaybackProgress(), traktService.getWatchedMovies() + traktService.getWatchedShows() ]); // Progress retrieval logging removed @@ -593,6 +594,28 @@ export function useTraktIntegration() { logger.error('[useTraktIntegration] Error preparing watched movie update:', error); } } + for (const show of watchedShows) { + try { + if (show.show?.ids?.imdb && show.seasons) { + const showImdbId = show.show.ids.imdb; + + for (const season of show.seasons) { + for (const episode of season.episodes) { + const episodeId = `${showImdbId}:${season.number}:${episode.number}`; + updatePromises.push( + storageService.mergeWithTraktProgress( + showImdbId, + 'series', + 100, + episode.last_watched_at, + episodeId + ) + ); + } + } + } + } catch (error) { + logger.error('[useTraktIntegration] Error preparing watched show update:', error); // Execute all updates in parallel await Promise.all(updatePromises); @@ -698,4 +721,4 @@ export function useTraktIntegration() { isInWatchlist, isInCollection }; -} \ No newline at end of file +}