From 35a6c1e5005fac7dab1bb9a3b6de72c23f295e96 Mon Sep 17 00:00:00 2001 From: optrader Date: Fri, 21 Nov 2025 09:56:10 +0900 Subject: [PATCH] [251121] fix: PlayerPanel tabIndexV2 = 2 from PopularShow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ๐Ÿ• ์ปค๋ฐ‹ ์‹œ๊ฐ„: 2025. 11. 21. 09:56:10 ๐Ÿ“Š ๋ณ€๊ฒฝ ํ†ต๊ณ„: โ€ข ์ด ํŒŒ์ผ: 1๊ฐœ โ€ข ์ถ”๊ฐ€: +89์ค„ โ€ข ์‚ญ์ œ: -27์ค„ ๐Ÿ“ ์ˆ˜์ •๋œ ํŒŒ์ผ: ~ com.twin.app.shoptime/src/views/PlayerPanel/PlayerPanel.jsx ๐Ÿ”ง ์ฃผ์š” ๋ณ€๊ฒฝ ๋‚ด์šฉ: โ€ข ์†Œ๊ทœ๋ชจ ๊ธฐ๋Šฅ ๊ฐœ์„  --- .../src/views/PlayerPanel/PlayerPanel.jsx | 116 ++++++++++++++---- 1 file changed, 89 insertions(+), 27 deletions(-) diff --git a/com.twin.app.shoptime/src/views/PlayerPanel/PlayerPanel.jsx b/com.twin.app.shoptime/src/views/PlayerPanel/PlayerPanel.jsx index 267c27d9..a72f39f9 100644 --- a/com.twin.app.shoptime/src/views/PlayerPanel/PlayerPanel.jsx +++ b/com.twin.app.shoptime/src/views/PlayerPanel/PlayerPanel.jsx @@ -47,7 +47,6 @@ import TPopUp from '../../components/TPopUp/TPopUp'; import Media from '../../components/VideoPlayer/Media'; import TReactPlayer from '../../components/VideoPlayer/TReactPlayer'; import { VideoPlayer } from '../../components/VideoPlayer/VideoPlayer'; -import usePrevious from '../../hooks/usePrevious'; import useWhyDidYouUpdate from '../../hooks/useWhyDidYouUpdate'; import * as Config from '../../utils/Config'; import { ACTIVE_POPUP, panel_names } from '../../utils/Config'; @@ -173,8 +172,8 @@ const PlayerPanel = ({ isTabActivated, panelInfo, isOnTop, spotlightId, ...props }); const videoPlayer = useRef(null); - const prevModal = usePrevious(panelInfo?.modal); - const prevIsTopPanelDetailFromPlayer = usePrevious(isTopPanelDetailFromPlayer); + const modalPrevRef = useRef(panelInfo?.modal); + const prevIsTopPanelDetailFromPlayerRef = useRef(false); const [playListInfo, setPlayListInfo] = USE_STATE('playListInfo', ''); const [shopNowInfo, setShopNowInfo] = USE_STATE('shopNowInfo'); const [backupInitialIndex, setBackupInitialIndex] = USE_STATE('backupInitialIndex', 0); @@ -213,6 +212,7 @@ const PlayerPanel = ({ isTabActivated, panelInfo, isOnTop, spotlightId, ...props const [isVODPaused, setIsVODPaused] = USE_STATE('isVODPaused', false); const [tabIndexV2, setTabIndexV2] = USE_STATE('tabIndexV2', 1); // 0: ShopNow, 1: LiveChannel, 2: ShopNowButton const [tabContainerVersion, setTabContainerVersion] = USE_STATE('tabContainerVersion', 2); // 1: TabContainer (์šฐ์ธก), 2: TabContainerV2 (ํ•˜๋‹จ) + const [isModalClosed, setIsModalClosed] = USE_STATE('isModalClosed', true); // ๋ชจ๋‹ฌ์ด false ์ƒํƒœ์ธ์ง€ ๋‚˜ํƒ€๋‚ด๋Š” ํ”Œ๋ž˜๊ทธ const panels = USE_SELECTOR('panels', (state) => state.panels.panels); const chatData = USE_SELECTOR('chatData', (state) => state.play.chatData); @@ -261,11 +261,11 @@ const PlayerPanel = ({ isTabActivated, panelInfo, isOnTop, spotlightId, ...props const lastPanelAction = USE_SELECTOR('lastPanelAction', (state) => state.panels.lastPanelAction); const nowMenu = USE_SELECTOR('nowMenu', (state) => state.common.menu.nowMenu); - const nowMenuRef = usePrevious(nowMenu); + const nowMenuRef = useRef(null); const entryMenu = USE_SELECTOR('entryMenu', (state) => state.common.menu.entryMenu); const [videoLoaded, setVideoLoaded] = USE_STATE('videoLoaded', false); - const entryMenuRef = usePrevious(entryMenu); - const panelInfoRef = usePrevious(panelInfo); + const entryMenuRef = useRef(null); + const panelInfoRef = useRef(null); const initialFocusTimeoutJob = useRef(new Job((func) => func(), 100)); const liveLogParamsRef = useRef(null); @@ -341,9 +341,30 @@ const PlayerPanel = ({ isTabActivated, panelInfo, isOnTop, spotlightId, ...props // } // },[isOnTop, panelInfo]) + // useRef๋“ค ์—…๋ฐ์ดํŠธ + // prevIsTopPanelDetailFromPlayerRef ์—…๋ฐ์ดํŠธ + useEffect(() => { + prevIsTopPanelDetailFromPlayerRef.current = isTopPanelDetailFromPlayer; + }, [isTopPanelDetailFromPlayer]); + + // nowMenuRef ์—…๋ฐ์ดํŠธ + useEffect(() => { + nowMenuRef.current = nowMenu; + }, [nowMenu]); + + // entryMenuRef ์—…๋ฐ์ดํŠธ + useEffect(() => { + entryMenuRef.current = entryMenu; + }, [entryMenu]); + + // panelInfoRef ์—…๋ฐ์ดํŠธ + useEffect(() => { + panelInfoRef.current = panelInfo; + }, [panelInfo]); + // PlayerPanel.jsx์˜ ๋ผ์ธ 313-327 useEffect ์ˆ˜์ • - detailPanelClosed flag ๊ฐ์ง€ ์ถ”๊ฐ€ useEffect(() => { - console.log('[PlayerPanel] isOnTop useEffect:', { + console.log('[PlayerPanel] ๐Ÿ” isOnTop useEffect ํ˜ธ์ถœ:', { isOnTop, modal: panelInfo?.modal, isPaused: panelInfo?.isPaused, @@ -354,18 +375,18 @@ const PlayerPanel = ({ isTabActivated, panelInfo, isOnTop, spotlightId, ...props // 1. Resume Video if needed (isPaused or detailPanelClosed) if (panelInfo.isPaused || panelInfo.detailPanelClosed) { if (panelInfo.modal) { - console.log('[PlayerPanel] Back on top (Modal) - resuming video'); + console.log('[PlayerPanel] โ–ถ๏ธ Back on top (Modal) - resuming video'); dispatch(resumeModalVideo()); } else { - console.log('[PlayerPanel] Back on top (Fullscreen) - resuming video'); + console.log('[PlayerPanel] โ–ถ๏ธ Back on top (Fullscreen) - resuming video'); dispatch(resumeFullscreenVideo()); } } // 2. Reset detailPanelClosed flag if (panelInfo.detailPanelClosed) { - console.log('[PlayerPanel] detailPanelClosed flag ์ดˆ๊ธฐํ™”'); - console.log('[PlayerPanel] Returned from DetailPanel', { + console.log('[PlayerPanel] ๐Ÿ”„ detailPanelClosed flag ์ดˆ๊ธฐํ™” ์‹œ์ž‘'); + console.log('[PlayerPanel] ๐Ÿ”™ DetailPanel์—์„œ ๋ณต๊ท€ ์ •๋ณด:', { detailPanelClosedAt: panelInfo.detailPanelClosedAt, detailPanelClosedFromSource: panelInfo.detailPanelClosedFromSource, lastFocusedTargetId: panelInfo.lastFocusedTargetId, @@ -376,7 +397,7 @@ const PlayerPanel = ({ isTabActivated, panelInfo, isOnTop, spotlightId, ...props console.log('[PlayerPanel] ๐ŸŽฏ DetailPanel ๋ณต๊ท€ ํ›„ 1000ms ์ง€์—ฐ ํฌ์ปค์Šค ๋ณต์› ์˜ˆ์•ฝ:', panelInfo.lastFocusedTargetId); const focusTimeoutId = setTimeout(() => { - console.log('[PlayerPanel] ๐ŸŽฏ DetailPanel ๋ณต๊ท€ ํ›„ ํฌ์ปค์Šค ๋ณต์› ์‹คํ–‰:', panelInfo.lastFocusedTargetId); + console.log('[PlayerPanel] ๐Ÿ” DetailPanel ๋ณต๊ท€ ํ›„ ํฌ์ปค์Šค ๋ณต์› ์‹คํ–‰:', panelInfo.lastFocusedTargetId); Spotlight.focus(panelInfo.lastFocusedTargetId); }, 1000); @@ -384,7 +405,7 @@ const PlayerPanel = ({ isTabActivated, panelInfo, isOnTop, spotlightId, ...props return () => { if (focusTimeoutId) { clearTimeout(focusTimeoutId); - console.log('[PlayerPanel] ๐ŸŽฏ ํฌ์ปค์Šค ๋ณต์› ํƒ€์ด๋จธ ์ •๋ฆฌ'); + console.log('[PlayerPanel] ๐Ÿงน ํฌ์ปค์Šค ๋ณต์› ํƒ€์ด๋จธ ์ •๋ฆฌ๋จ'); } }; } @@ -400,11 +421,12 @@ const PlayerPanel = ({ isTabActivated, panelInfo, isOnTop, spotlightId, ...props }, }) ); + console.log('[PlayerPanel] ๐Ÿ detailPanelClosed flag ์ดˆ๊ธฐํ™” ์™„๋ฃŒ'); } } else { // Not on top if (panelInfo && panelInfo.modal) { - // console.log('[PlayerPanel] Not on top - pausing video'); + console.log('[PlayerPanel] โธ๏ธ Not on top (Modal) - pausing video logic commented out'); // dispatch(pauseModalVideo()); } } @@ -422,11 +444,23 @@ const PlayerPanel = ({ isTabActivated, panelInfo, isOnTop, spotlightId, ...props } }, [panelInfo?.isPaused]); - // Modal ์ƒํƒœ ๋ณ€ํ™” ๊ฐ์ง€ (true โ†’ false) + // Modal ์ƒํƒœ ๋ณ€ํ™” ๊ฐ์ง€ (true โ†’ false, false โ†’ true) useEffect(() => { - if (prevModal !== undefined && prevModal === true && panelInfo?.modal === false) { - console.log('[PlayerPanel] ๐Ÿ”„ Modal ์ƒํƒœ ๋ณ€ํ™”: true โ†’ false (์ „์ฒดํ™”๋ฉด ๋ชจ๋“œ๋กœ ๋ณต๊ท€)'); + const currentModalState = panelInfo?.modal; + const prevModalState = modalPrevRef.current; + + console.log('[PlayerPanel] ๐Ÿ” Modal ์ƒํƒœ ์ฒดํฌ:', { + prevModalState, + currentModalState, + shouldExecuteTrueToFalse: prevModalState === true && currentModalState === false, + shouldExecuteFalseToTrue: prevModalState === false && currentModalState === true + }); + + // true โ†’ false ๋ณ€ํ™” ๊ฐ์ง€ + if (prevModalState === true && currentModalState === false) { + console.log('[PlayerPanel] โ–ถ๏ธ Modal ์ƒํƒœ ๋ณ€ํ™”: true โ†’ false (์ „์ฒดํ™”๋ฉด ๋ชจ๋“œ๋กœ ๋ณต๊ท€)'); console.log('[PlayerPanel] ๐ŸŽฏ ํฌ์ปค์Šค ๋ณต์› ์ค€๋น„ - lastFocusedTargetId:', panelInfo?.lastFocusedTargetId); + setIsModalClosed(true); // ๋ชจ๋‹ฌ์ด ๋‹ซํ˜”์Œ์„ ํ‘œ์‹œ // DetailPanel์—์„œ ๋ณต๊ท€ ์‹œ ํฌ์ปค์Šค ๋ณต์› const lastFocusedTargetId = panelInfo?.lastFocusedTargetId; @@ -439,7 +473,15 @@ const PlayerPanel = ({ isTabActivated, panelInfo, isOnTop, spotlightId, ...props }, 800); } } - }, [panelInfo?.modal, prevModal, panelInfo?.lastFocusedTargetId]); + + // false โ†’ true ๋ณ€ํ™” ๊ฐ์ง€ (๋ชจ๋‹ฌ์ด ์—ด๋ฆผ) + if (prevModalState === false && currentModalState === true) { + console.log('[PlayerPanel] ๐Ÿ“ฑ Modal ์ƒํƒœ ๋ณ€ํ™”: false โ†’ true (๋ชจ๋‹ฌ ์—ด๋ฆผ)'); + setIsModalClosed(false); // ๋ชจ๋‹ฌ์ด ์—ด๋ ธ์Œ์„ ํ‘œ์‹œ + } + + modalPrevRef.current = currentModalState; // ํ˜„์žฌ modal ์ƒํƒœ๋ฅผ ref์— ์ €์žฅ + }, [panelInfo?.modal, panelInfo?.lastFocusedTargetId]); // creating live log params useEffect(() => { @@ -2117,20 +2159,25 @@ const PlayerPanel = ({ isTabActivated, panelInfo, isOnTop, spotlightId, ...props useEffect(() => { if (isOnTop && !panelInfo.modal && !videoVerticalVisible) { // ์ •ํ™•ํ•œ ๋ณต๊ท€ ์ข…๋ฅ˜ ๊ตฌ๋ถ„: - // 1. HomePanel ๋ณต๊ท€: prevModal === true && prevIsTopPanelDetailFromPlayer === false - // 2. DetailPanel ๋ณต๊ท€: prevIsTopPanelDetailFromPlayer === true - const isHomePanelReturn = prevModal === true && prevIsTopPanelDetailFromPlayer === false; - const isDetailPanelReturn = prevIsTopPanelDetailFromPlayer === true; + // 1. HomePanel ๋ณต๊ท€: modalPrevRef.current === true && prevIsTopPanelDetailFromPlayerRef.current === false + // 2. DetailPanel ๋ณต๊ท€: prevIsTopPanelDetailFromPlayerRef.current === true + const isHomePanelReturn = modalPrevRef.current === true && prevIsTopPanelDetailFromPlayerRef.current === false; + const isDetailPanelReturn = prevIsTopPanelDetailFromPlayerRef.current === true; if (isDetailPanelReturn) { console.log('[PlayerPanel] โœ… PlayerPanel ๋‚ด๋ถ€ DetailPanel์—์„œ ๋ณต๊ท€ํ•จ! - ์˜ค๋ฒ„๋ ˆ์ด ํ‘œ์‹œ'); } else if (isHomePanelReturn) { console.log('[PlayerPanel] ๐Ÿ“บ HomePanel์—์„œ ๋ณต๊ท€ํ•จ - ์˜ค๋ฒ„๋ ˆ์ด ํ‘œ์‹œ'); - // HomePanel์—์„œ ๋ณต๊ท€ ์‹œ ํ•ญ์ƒ tabIndex=1๋กœ ์‹œ์ž‘ - console.log('[PlayerPanel] ๐Ÿ”„ HomePanel ๋ณต๊ท€ - tabIndex๋ฅผ 1๋กœ ๊ฐ•์ œ ์„ค์ •'); + // HomePanel์—์„œ ๋ณต๊ท€ ์‹œ ์ฝ˜ํ…์ธ  ํƒ€์ž…์— ๋”ฐ๋ผ tabIndex ์„ค์ • + console.log('[PlayerPanel] ๐Ÿ”„ HomePanel ๋ณต๊ท€ - tabIndex๋ฅผ ์ฝ˜ํ…์ธ  ํƒ€์ž…์— ๋”ฐ๋ผ ์„ค์ •'); if (tabContainerVersion === 2) { - setTabIndexV2(1); - console.log('[PlayerPanel] ๐Ÿ“ tabIndexV2๋ฅผ 1๋กœ ์„ค์ •๋จ'); + if (panelInfoRef.current.shptmBanrTpNm === 'VOD') { + setTabIndexV2(2); + console.log('[PlayerPanel] ๐Ÿ“ VOD ์ฝ˜ํ…์ธ  - tabIndexV2๋ฅผ 2๋กœ ์„ค์ •๋จ'); + } else { + setTabIndexV2(1); + console.log('[PlayerPanel] ๐Ÿ“ LIVE ์ฝ˜ํ…์ธ  - tabIndexV2๋ฅผ 1๋กœ ์„ค์ •๋จ'); + } } } else { console.log('[PlayerPanel] ๐Ÿ”„ ๊ทธ ์™ธ ๋ณต๊ท€ - ์˜ค๋ฒ„๋ ˆ์ด ํ‘œ์‹œ'); @@ -2155,7 +2202,22 @@ const PlayerPanel = ({ isTabActivated, panelInfo, isOnTop, spotlightId, ...props } } } - }, [isOnTop, panelInfo.modal, videoVerticalVisible, panelInfo?.lastFocusedTargetId, tabContainerVersion, setTabIndexV2, prevModal, prevIsTopPanelDetailFromPlayer]); + }, [isOnTop, panelInfo.modal, videoVerticalVisible, panelInfo?.lastFocusedTargetId, tabContainerVersion, setTabIndexV2]); + + // PopularShow์—์„œ ์ฒ˜์Œ ํ˜ธ์ถœํ•  ๋•Œ์ฒ˜๋Ÿผ modal์ด false์ธ ์ƒํƒœ์—์„œ VOD/LIVE ๊ตฌ๋ถ„ + useEffect(() => { + if (isOnTop && !panelInfo.modal && !videoVerticalVisible && tabContainerVersion === 2) { + console.log('[PlayerPanel] ๐Ÿ“บ Modal false ์ƒํƒœ - shptmBanrTpNm:', panelInfoRef.current?.shptmBanrTpNm); + + if (panelInfoRef.current?.shptmBanrTpNm === 'VOD') { + setTabIndexV2(2); + console.log('[PlayerPanel] ๐Ÿ“ VOD ์ฝ˜ํ…์ธ  - tabIndexV2๋ฅผ 2๋กœ ์„ค์ •๋จ'); + } else { + setTabIndexV2(1); + console.log('[PlayerPanel] ๐Ÿ“ LIVE ์ฝ˜ํ…์ธ  - tabIndexV2๋ฅผ 1๋กœ ์„ค์ •๋จ'); + } + } + }, [isOnTop, panelInfo.modal, videoVerticalVisible, tabContainerVersion]); useEffect(() => { // tabContainerVersion === 1์ผ ๋•Œ๋งŒ ์‹คํ–‰