From 2ebec55bbc45c428d0dfa01b14c5085d99b54af8 Mon Sep 17 00:00:00 2001 From: tapframe Date: Thu, 8 Jan 2026 15:03:59 +0530 Subject: [PATCH] updated continue watching logic to render only last 30 watch progress --- .../home/ContinueWatchingSection.tsx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/components/home/ContinueWatchingSection.tsx b/src/components/home/ContinueWatchingSection.tsx index ef56634..60cdc66 100644 --- a/src/components/home/ContinueWatchingSection.tsx +++ b/src/components/home/ContinueWatchingSection.tsx @@ -395,13 +395,18 @@ const ContinueWatchingSection = React.forwardRef((props, re return; } - // Group progress items by content ID + // Group progress items by content ID - process ONLY last 30 items + const sortedProgress = Object.entries(allProgress) + .sort(([, a], [, b]) => b.lastUpdated - a.lastUpdated) + .slice(0, 30); + const contentGroups: Record }> = {}; - for (const key in allProgress) { + + for (const [key, progress] of sortedProgress) { const keyParts = key.split(':'); const [type, id, ...episodeIdParts] = keyParts; const episodeId = episodeIdParts.length > 0 ? episodeIdParts.join(':') : undefined; - const progress = allProgress[key]; + const progressPercent = progress.duration > 0 ? (progress.currentTime / progress.duration) * 100 @@ -682,7 +687,13 @@ const ContinueWatchingSection = React.forwardRef((props, re // STEP 1: Process playback progress items (in-progress, paused) // These have actual progress percentage from Trakt const thirtyDaysAgo = Date.now() - (30 * 24 * 60 * 60 * 1000); - for (const item of playbackItems) { + + // Sort by paused_at descending and take top 30 + const sortedPlaybackItems = playbackItems + .sort((a, b) => new Date(b.paused_at).getTime() - new Date(a.paused_at).getTime()) + .slice(0, 30); + + for (const item of sortedPlaybackItems) { try { // Skip items with < 2% progress (accidental clicks) if (item.progress < 2) continue;