From 4ea13b5d6cd91822773786ffbb1a2964868af23f Mon Sep 17 00:00:00 2001 From: tapframe Date: Mon, 28 Jul 2025 17:43:01 +0530 Subject: [PATCH] fix --- .../home/ContinueWatchingSection.tsx | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/components/home/ContinueWatchingSection.tsx b/src/components/home/ContinueWatchingSection.tsx index 82ccfa4..9ed120f 100644 --- a/src/components/home/ContinueWatchingSection.tsx +++ b/src/components/home/ContinueWatchingSection.tsx @@ -73,6 +73,20 @@ const isValidImdbId = (id: string): boolean => { return imdbPattern.test(id); }; +// Function to check if an episode has been released +const isEpisodeReleased = (video: any): boolean => { + if (!video.released) return false; + + try { + const releaseDate = new Date(video.released); + const now = new Date(); + return releaseDate <= now; + } catch (error) { + // If we can't parse the date, assume it's not released + return false; + } +}; + // Create a proper imperative handle with React.forwardRef and updated type const ContinueWatchingSection = React.forwardRef((props, ref) => { const navigation = useNavigation>(); @@ -211,13 +225,13 @@ const ContinueWatchingSection = React.forwardRef((props, re } } - // Check if next episode exists using cached metadata + // Check if next episode exists and has been released using cached metadata if (nextSeason !== undefined && nextEpisode !== undefined && metadata?.videos && Array.isArray(metadata.videos)) { - const nextEpisodeExists = metadata.videos.some((video: any) => + const nextEpisodeVideo = metadata.videos.find((video: any) => video.season === nextSeason && video.episode === nextEpisode ); - if (nextEpisodeExists) { + if (nextEpisodeVideo && isEpisodeReleased(nextEpisodeVideo)) { const nextEpisodeItem = { ...basicContent, id: group.id, @@ -331,15 +345,15 @@ const ContinueWatchingSection = React.forwardRef((props, re if (!cachedData?.basicContent) return; const { metadata, basicContent } = cachedData; - let nextEpisodeExists = false; + let nextEpisodeVideo = null; if (metadata?.videos && Array.isArray(metadata.videos)) { - nextEpisodeExists = metadata.videos.some((video: any) => + nextEpisodeVideo = metadata.videos.find((video: any) => video.season === info.season && video.episode === nextEpisode ); } - if (nextEpisodeExists) { + if (nextEpisodeVideo && isEpisodeReleased(nextEpisodeVideo)) { const placeholder: ContinueWatchingItem = { ...basicContent, id: showId,