diff --git a/com.twin.app.shoptime/src/views/PlayerPanel/PlayerPanel.jsx b/com.twin.app.shoptime/src/views/PlayerPanel/PlayerPanel.jsx index 17e96d97..2f3d97dd 100644 --- a/com.twin.app.shoptime/src/views/PlayerPanel/PlayerPanel.jsx +++ b/com.twin.app.shoptime/src/views/PlayerPanel/PlayerPanel.jsx @@ -322,6 +322,7 @@ const PlayerPanel = ({ const mediaLogParamsRef = useRef(null); const prevNowMenuRef = useRef(null); const watchInterval = useRef(null); + const liveShowEndCalledRef = useRef(false); const currentLiveShowInfo = useMemo(() => { if (liveShowInfos && liveShowInfos.length > 0) { @@ -1087,7 +1088,6 @@ const PlayerPanel = ({ }, [ dispatch, panelInfo?.curationId, - panelInfo?.lgCatCd, panelInfo?.patnrId, panelInfo?.showId, panelInfo?.shptmBanrTpNm, @@ -1272,7 +1272,21 @@ const PlayerPanel = ({ playlist.forEach((item) => { if (item.showType === "vod" && Array.isArray(item.vodInfos)) { - const mergedVodInfos = item.vodInfos.map((vod) => ({ + // vodInfos를 정렬 (showId 기준) + const sortedVodInfos = [...item.vodInfos].sort((a, b) => { + // showId가 있으면 showId로 정렬 + if (a.showId && b.showId) { + return a.showId.localeCompare(b.showId); + } + // strtDt가 있으면 시작일로 정렬 + if (a.strtDt && b.strtDt) { + return new Date(a.strtDt) - new Date(b.strtDt); + } + // 정렬 기준이 없으면 원래 순서 유지 + return 0; + }); + + const mergedVodInfos = sortedVodInfos.map((vod) => ({ ...vod, patnrId: item.patnrId, patncNm: item.patncNm, @@ -1402,8 +1416,17 @@ const PlayerPanel = ({ } }, [liveTotalTime]); + // showId 변경 시 liveShowEndCalled 리셋 useEffect(() => { - if (currentLiveTimeSeconds > liveTotalTime) { + liveShowEndCalledRef.current = false; + }, [panelInfo?.showId]); + + useEffect(() => { + if ( + currentLiveTimeSeconds > liveTotalTime && + !liveShowEndCalledRef.current + ) { + liveShowEndCalledRef.current = true; setTimeout(() => { dispatch(getMainLiveShow()); setShopNowInfo("");