[PlayerPanel] 30초마다 ShopNow Item 갱신 API 호출

This commit is contained in:
고동영
2024-06-14 10:32:17 +09:00
parent 1f2025c14f
commit 5a114ed22c
2 changed files with 34 additions and 22 deletions

View File

@@ -1,8 +1,8 @@
import { URLS } from '../api/apiConfig';
import { TAxios } from '../api/TAxios';
import { CATEGORY_DATA_MAX_RESULTS_LIMIT } from '../utils/Config';
import * as HelperMethods from '../utils/helperMethods';
import { types } from './actionTypes';
import { URLS } from "../api/apiConfig";
import { TAxios } from "../api/TAxios";
import { CATEGORY_DATA_MAX_RESULTS_LIMIT } from "../utils/Config";
import * as HelperMethods from "../utils/helperMethods";
import { types } from "./actionTypes";
export const getMainLiveShow = (props) => (dispatch, getState) => {
const onSuccess = (response) => {
@@ -339,7 +339,7 @@ export const getHomeFullVideoInfo =
// 메인화면 Live 현재 방송 상품 조회 IF-LGSP-046
export const getMainLiveShowNowProduct =
({ patnrId, showId }) =>
({ patnrId, showId, lstChgDt }) =>
(dispatch, getState) => {
const onSuccess = (response) => {
console.log("getMainLiveShowNowProduct onSuccess", response.data);
@@ -359,7 +359,7 @@ export const getMainLiveShowNowProduct =
getState,
"get",
URLS.GET_MAIN_LIVE_SHOW_NOW_PRODUCT,
{ patnrId, showId },
{ patnrId, showId, lstChgDt },
{},
onSuccess,
onFail

View File

@@ -325,6 +325,28 @@ const PlayerPanel = ({
};
}, [panelInfo?.modal, isOnTop]);
useEffect(() => {
if (showNowInfos) {
const period =
showNowInfos.period !== undefined ? showNowInfos.period : 30;
const periodInMilliseconds = period * 1000;
const timer = setTimeout(() => {
dispatch(
getMainLiveShowNowProduct({
patnrId: panelInfo.patnrId,
showId: panelInfo.showId,
lstChgDt: showNowInfos.lstChgDt,
})
);
}, periodInMilliseconds);
return () => {
clearTimeout(timer);
};
}
}, [showNowInfos, panelInfo]);
const cannotPlay = useMemo(() => {
const topPanel = panels[panels.length - 1];
return !isOnTop && topPanel?.name === panel_names.PLAYER_PANEL;
@@ -469,6 +491,11 @@ const PlayerPanel = ({
case "LIVE": {
const playlist = liveChannelInfos ? liveChannelInfos : liveShowInfos;
setPlayListInfo(playlist);
if (showNowInfos?.productInfos === null) {
return;
}
if (showNowInfos || showDetailInfo?.length > 0) {
const productInfos = showNowInfos
? showNowInfos.productInfos
@@ -492,21 +519,6 @@ const PlayerPanel = ({
dispatch,
]);
// 일정시간마다 API를 재호출해야하는 기능 테스트기간 동안 주석
useEffect(() => {
if (panelInfo?.shptmBanrTpNm === "LIVE") {
const interval = setInterval(() => {
dispatch(
getMainLiveShowNowProduct({
patnrId: panelInfo.patnrId,
showId: panelInfo.showId,
})
);
}, 10000); // 10초마다 호출
return () => clearInterval(interval);
}
}, [panelInfo, dispatch]);
const mediainfoHandler = useCallback(
(ev) => {
const type = ev.type;