From f90bbea1bbe9c2bda8c1bf1514f173bcf1b0d626 Mon Sep 17 00:00:00 2001 From: paregi12 Date: Mon, 9 Feb 2026 22:03:21 +0530 Subject: [PATCH] fix(player): prevent Up Next fallback from triggering early when outro exists --- src/components/player/common/UpNextButton.tsx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/components/player/common/UpNextButton.tsx b/src/components/player/common/UpNextButton.tsx index 235ca6a2..77f44416 100644 --- a/src/components/player/common/UpNextButton.tsx +++ b/src/components/player/common/UpNextButton.tsx @@ -80,17 +80,16 @@ const UpNextButton: React.FC = ({ const shouldShow = useMemo(() => { if (!nextEpisode || duration <= 0) return false; - // 1. Check for Outro-based trigger - if (outroSegment) { - const timeRemainingAtOutroEnd = duration - outroSegment.endTime; - // Only trigger if the outro ends within the last 5 minutes (300s) - // This prevents mid-episode "fake" outros from triggering it too early - if (timeRemainingAtOutroEnd < 300 && currentTime >= outroSegment.endTime) { - return true; - } + // 1. Determine if we have a valid ending outro (within last 5 mins) + const hasValidEndingOutro = outroSegment && (duration - outroSegment.endTime < 300); + + if (hasValidEndingOutro) { + // If we have a valid outro, ONLY show after it finishes + // This prevents the 60s fallback from "jumping the gun" + return currentTime >= outroSegment.endTime; } - // 2. Standard Fallback (60s remaining) + // 2. Standard Fallback (only if no valid ending outro was found) const timeRemaining = duration - currentTime; return timeRemaining < 61 && timeRemaining > 0; }, [nextEpisode, duration, currentTime, outroSegment]);