change logic when entering deep link (api call)

This commit is contained in:
hyunwoo93.cha
2024-07-19 16:46:15 +09:00
parent 9d49fa0b8a
commit de6c987b7d
6 changed files with 82 additions and 57 deletions

View File

@@ -1,56 +1,45 @@
import React, {
useCallback,
useEffect,
useMemo,
useRef,
useState,
} from 'react';
} from "react";
import {
useDispatch,
useSelector,
} from 'react-redux';
import { useDispatch, useSelector } from "react-redux";
import platform from '@enact/core/platform';
import { Job } from '@enact/core/util';
import ThemeDecorator from '@enact/sandstone/ThemeDecorator';
import Spotlight from '@enact/spotlight';
import platform from "@enact/core/platform";
import { Job } from "@enact/core/util";
import ThemeDecorator from "@enact/sandstone/ThemeDecorator";
import Spotlight from "@enact/spotlight";
import appinfo from '../../webos-meta/appinfo.json';
import appinfo from "../../webos-meta/appinfo.json";
import {
changeAppStatus,
getDeviceId,
getHttpHeaderForServiceRequest,
getSystemSettings,
} from '../actions/commonActions';
import { getShoptimeTerms } from '../actions/empActions';
import {
getHomeMenu,
getHomeTerms,
} from '../actions/homeActions';
setDeepLink,
} from "../actions/commonActions";
import { getShoptimeTerms } from "../actions/empActions";
import { getHomeMenu, getHomeTerms } from "../actions/homeActions";
import { sendLogSecondLayer } from "../actions/logActions";
import {
getMyRecommandedKeyword,
getMyUpcomingAlertShow,
setMyTermsWithdraw,
} from '../actions/myPageActions';
import { pushPanel } from '../actions/panelActions';
import {
countryCode,
ricCode,
} from '../api/apiConfig';
import TPopUp from '../components/TPopUp/TPopUp';
import usePrevious from '../hooks/usePrevious';
import { checkValidCountry } from '../lunaSend/common';
import { lunaTest } from '../lunaSend/lunaTest';
import * as Config from '../utils/Config';
import {
$L,
clearLaunchParams,
getLaunchParams,
} from '../utils/helperMethods';
import MainView from '../views/MainView/MainView';
import css from './App.module.less';
import { handleDeepLink } from './deepLinkHandler';
import { sendLogSecondLayer } from '../actions/logActions';
} from "../actions/myPageActions";
import { pushPanel } from "../actions/panelActions";
import { countryCode, ricCode } from "../api/apiConfig";
import TPopUp from "../components/TPopUp/TPopUp";
import usePrevious from "../hooks/usePrevious";
import { checkValidCountry } from "../lunaSend/common";
import { lunaTest } from "../lunaSend/lunaTest";
import * as Config from "../utils/Config";
import { $L, clearLaunchParams, getLaunchParams } from "../utils/helperMethods";
import MainView from "../views/MainView/MainView";
import css from "./App.module.less";
import { handleDeepLink } from "./deepLinkHandler";
let foreGroundChangeTimer = null;
@@ -103,9 +92,9 @@ function AppBase(props) {
console.log("hide cursor");
}, 5000)
);
const _sendLogSecondLayer = useCallback((params)=>{
const _sendLogSecondLayer = useCallback((params) => {
dispatch(sendLogSecondLayer(params));
},[]);
}, []);
// called by [receive httpHeader, launch, relaunch]
const initService = useCallback(
@@ -283,6 +272,14 @@ function AppBase(props) {
}
}, [introTermsAgree, dispatch]);
useEffect(() => {
const launchParmas = getLaunchParams();
if (launchParmas.contentTarget) {
dispatch(setDeepLink(true));
}
}, [dispatch]);
return (
<MainView
className={

View File

@@ -29,6 +29,7 @@ export const types = {
SET_GNB_MENU: "SET_GNB_MENU",
SET_SYSTEM_NOTICE: "SET_SYSTEM_NOTICE",
SET_SYSTEM_TERMINATION: "SET_SYSTEM_TERMINATION",
SET_DEEP_LINK: "SET_DEEP_LINK",
// billing actions
GET_MY_INFO_BILLING_SEARCH: "GET_MY_INFO_BILLING_SEARCH",

View File

@@ -435,3 +435,8 @@ export const setSystemTermination = (isinitialLoad) => ({
tpe: types.SET_SYSTEM_TERMINATION,
payload: { isinitialLoad },
});
export const setDeepLink = (isDeepLink) => ({
type: types.SET_DEEP_LINK,
payload: isDeepLink,
});

View File

@@ -61,6 +61,8 @@ const initialState = {
// test
spotlightId: null,
isDeepLink: false,
};
export const commonReducer = (state = initialState, action) => {
@@ -238,6 +240,13 @@ export const commonReducer = (state = initialState, action) => {
};
}
case types.SET_DEEP_LINK: {
return {
...state,
isDeepLink: action.payload,
};
}
default:
return state;
}

View File

@@ -137,6 +137,7 @@ let localLaunchParams = {
// contentTarget: "V3_8001_Tv_SC_1000_Fashion_Item",
// contentTarget: "V3_8001_Tv_FB_1",
// contentTarget: "V3_8001_Tv_TC_824",
contentTarget: "V3_2000_HOMEBANNER:TOP_MT_1",
};
export const getLaunchParams = () => {

View File

@@ -13,6 +13,7 @@ import Spotlight from "@enact/spotlight";
import {
changeAppStatus,
setDeepLink,
setExitApp,
setHidePopup,
setShowPopup,
@@ -24,6 +25,7 @@ import {
getHomeMainContents,
updateSpotlightId,
} from "../../actions/homeActions";
import { sendLogGNB } from "../../actions/logActions";
import { getSubCategory, getTop20Show } from "../../actions/mainActions";
import { getHomeOnSaleInfo } from "../../actions/onSaleActions";
import { finishVideoPreview } from "../../actions/playActions";
@@ -45,7 +47,6 @@ import css from "../HomePanel/HomePanel.module.less";
import PopularShow from "../HomePanel/PopularShow/PopularShow";
import SubCategory from "../HomePanel/SubCategory/SubCategory";
import EventPopUpBanner from "./EventPopUpBanner/EventPopUpBanner";
import { sendLogGNB } from "../../actions/logActions";
const TEMPLATE_CODE_CONF = {
TOP: "DSP00101",
@@ -101,6 +102,7 @@ export default function HomePanel({ isOnTop }) {
(state) => state.product.bestSellerData?.bestSeller
);
const topInfos = useSelector((state) => state.main.top20ShowData.topInfos);
const isDeepLink = useSelector((state) => state.common.isDeepLink);
const [btnDisabled, setBtnDisabled] = useState(true);
const [arrowBottom, setArrowBottom] = useState(true);
@@ -116,7 +118,9 @@ export default function HomePanel({ isOnTop }) {
const [focusedContainerId, setFocusedContainerId] = useState(
panelInfo.focusedContainerId
);
const [initialLoadDone, setInitialLoadDone] = useState(false);
const isInitialRender = useRef(true);
const verticalPagenatorRef = useRef(null);
const sendedNowMenuRef = useRef(null);
@@ -381,25 +385,33 @@ export default function HomePanel({ isOnTop }) {
}, []);
useEffect(() => {
if (panels.length > 0 || panelInfo.focusedContainerId) {
//ignore patch
return;
if (isInitialRender.current) {
isInitialRender.current = false;
if (isDeepLink || (!panels.length && !panelInfo.focusedContainerId)) {
dispatch(
changeAppStatus({ showLoadingPanel: { show: true, type: "wait" } })
);
dispatch(getHomeMainContents());
dispatch(getHomeLayout());
dispatch(
getHomeOnSaleInfo({
homeSaleInfosIncFlag: "Y",
categoryIncFlag: "Y",
saleInfosIncFlag: "N",
})
);
dispatch(getTop20Show());
dispatch(getBestSeller(bestSellerLoaded));
setInitialLoadDone(true);
if (isDeepLink) {
dispatch(setDeepLink(false));
}
}
}
dispatch(
changeAppStatus({ showLoadingPanel: { show: true, type: "wait" } })
);
dispatch(getHomeMainContents());
dispatch(getHomeLayout());
dispatch(
getHomeOnSaleInfo({
homeSaleInfosIncFlag: "Y",
categoryIncFlag: "Y",
saleInfosIncFlag: "N",
})
);
dispatch(getTop20Show());
dispatch(getBestSeller(bestSellerLoaded));
}, [dispatch]);
}, [dispatch, isDeepLink, panels.length, panelInfo.focusedContainerId]);
useEffect(() => {
doSendLogGNB(focusedContainerId);