From 9037a09421441c52c34c7f18a7ca39d2718de89f Mon Sep 17 00:00:00 2001 From: chrisk325 Date: Sun, 1 Mar 2026 19:53:14 +0530 Subject: [PATCH] fix continue watching sort order yet again (edge cases) --- .../home/ContinueWatchingSection.tsx | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/components/home/ContinueWatchingSection.tsx b/src/components/home/ContinueWatchingSection.tsx index 0d4617a5..2c303f09 100644 --- a/src/components/home/ContinueWatchingSection.tsx +++ b/src/components/home/ContinueWatchingSection.tsx @@ -371,16 +371,9 @@ const ContinueWatchingSection = React.forwardRef((props, re }; const compareCwItems = (a: ContinueWatchingItem, b: ContinueWatchingItem): number => { - const aProgress = a.progress ?? 0; - const bProgress = b.progress ?? 0; - const aIsUpNext = a.type === 'series' && aProgress <= 0; - const bIsUpNext = b.type === 'series' && bProgress <= 0; - - // Keep active in-progress items ahead of "Up Next" placeholders. - if (aIsUpNext !== bIsUpNext) { - return aIsUpNext ? 1 : -1; - } - + // Sort purely by recency — most recently watched first. + // "Up Next" placeholders (progress=0) carry the timestamp of the last watched episode + // so they naturally bubble up next to the other recently-watched items. return (b.lastUpdated ?? 0) - (a.lastUpdated ?? 0); }; @@ -1199,13 +1192,13 @@ const ContinueWatchingSection = React.forwardRef((props, re if (!mostRecentLocal || !highestLocal) return it; - // IMPORTANT: - // In Trakt-auth mode, the "most recently watched" ordering should reflect local playback, - // not Trakt's paused_at (which can be stale or even appear newer than local). - // So: if we have any local match, use its timestamp for ordering. - const mergedLastUpdated = (mostRecentLocal.lastUpdated ?? 0) > 0 - ? (mostRecentLocal.lastUpdated ?? 0) - : (it.lastUpdated ?? 0); + // Use the most recent timestamp between local and Trakt. + // Always preferring local was wrong: if you watched on another device, + // Trakt's paused_at is newer and should win for ordering purposes. + const mergedLastUpdated = Math.max( + (mostRecentLocal.lastUpdated ?? 0), + (it.lastUpdated ?? 0) + ); try { logger.log('[CW][Trakt][Overlay] item/local summary', {