[App] dispatch 추가

Detail Notes :

1. getOnSaleInfo를 통한 api 데이터의 범용성으로 App.js 이동
This commit is contained in:
younghoon100.park
2024-02-06 14:29:43 +09:00
parent db6cb4c260
commit 4648c5db56

View File

@@ -1,30 +1,29 @@
import React, { useCallback, useEffect } from 'react'; import React, { useCallback, useEffect } from "react";
import { useDispatch } from 'react-redux'; import { useDispatch } from "react-redux";
import ThemeDecorator from '@enact/sandstone/ThemeDecorator'; import platform from "@enact/core/platform";
import platform from '@enact/core/platform'; import ThemeDecorator from "@enact/sandstone/ThemeDecorator";
import { getBrandList } from '../actions/brandActions';
import { getAuthenticationCode } from '../actions/deviceActions'; import appinfo from "../../webos-meta/appinfo.json";
import { getBrandList } from "../actions/brandActions";
import { changeAppStatus } from "../actions/commonActions";
import { getAuthenticationCode } from "../actions/deviceActions";
import { import {
getHomeLayout, getHomeLayout,
getHomeMainContents, getHomeMainContents,
getHomeMenu, getHomeMenu,
getThemeCurationInfo, getThemeCurationInfo,
} from '../actions/homeActions'; } from "../actions/homeActions";
import { import { getSubCategory, getTop20Show } from "../actions/mainActions";
getSubCategory, import { getMyRecommandedKeyword } from "../actions/myPageActions";
getTop20Show, import { getOnSaleInfo } from "../actions/onSaleActions";
} from '../actions/mainActions'; import { getBestSeller } from "../actions/productActions";
import { getMyRecommandedKeyword } from '../actions/myPageActions';
import { getBestSeller } from '../actions/productActions';
import MainView from '../views/MainView/MainView';
import { lunaTest } from "../lunaSend/lunaTest"; import { lunaTest } from "../lunaSend/lunaTest";
import appinfo from '../../webos-meta/appinfo.json'; import { getLaunchParams } from "../utils/helperMethods";
import css from './App.module.less'; import MainView from "../views/MainView/MainView";
import { getLaunchParams } from '../utils/helperMethods'; import css from "./App.module.less";
import { changeAppStatus } from '../actions/commonActions'; import { handleDeepLink } from "./deepLinkHandler";
import { handleDeepLink } from './deepLinkHandler';
let foreGroundChangeTimer = null; let foreGroundChangeTimer = null;
@@ -33,11 +32,19 @@ function AppBase(props) {
const initService = useCallback( const initService = useCallback(
(haveyInit = true) => { (haveyInit = true) => {
console.log( "<<<<<<<<<<<<< appinfo >>>>>>>>>>>>{heavyInit, appinfo} ", haveyInit, appinfo); console.log(
"<<<<<<<<<<<<< appinfo >>>>>>>>>>>>{heavyInit, appinfo} ",
haveyInit,
appinfo
);
if (haveyInit) { if (haveyInit) {
dispatch(changeAppStatus({ connectionFailed: false })); dispatch(changeAppStatus({ connectionFailed: false }));
if (typeof window === "object" && window.PalmSystem) { if (typeof window === "object" && window.PalmSystem) {
dispatch(changeAppStatus({ cursorVisible: window.PalmSystem?.cursor?.visibility })); dispatch(
changeAppStatus({
cursorVisible: window.PalmSystem?.cursor?.visibility,
})
);
} }
//todo //todo
// dispatch(getSystemSettings()); // dispatch(getSystemSettings());
@@ -48,6 +55,7 @@ function AppBase(props) {
// dispatch(getHttpHeaderForServiceRequest(webOSVersion, language)); // dispatch(getHttpHeaderForServiceRequest(webOSVersion, language));
dispatch(getAuthenticationCode()); dispatch(getAuthenticationCode());
dispatch(getOnSaleInfo({ categoryIncFlag: "Y", lgCatCd: "" }));
dispatch(getHomeMenu()); dispatch(getHomeMenu());
dispatch(getHomeLayout()); dispatch(getHomeLayout());
dispatch(getHomeMainContents()); dispatch(getHomeMainContents());
@@ -67,12 +75,18 @@ function AppBase(props) {
dispatch(getThemeCurationInfo()); dispatch(getThemeCurationInfo());
} }
}, },
[dispatch]); [dispatch]
);
const handleLaunchEvent = useCallback((isRelaunch=false)=>{ const handleLaunchEvent = useCallback(
(isRelaunch = false) => {
//todo deeplink //todo deeplink
const launchParams = getLaunchParams(); const launchParams = getLaunchParams();
console.log('handleLaunchEvent...{isRelaunch, launchParams}', isRelaunch, launchParams); console.log(
"handleLaunchEvent...{isRelaunch, launchParams}",
isRelaunch,
launchParams
);
if (launchParams?.contentTarget) { if (launchParams?.contentTarget) {
//todo deeplink //todo deeplink
@@ -82,7 +96,9 @@ function AppBase(props) {
setTimeout(() => { setTimeout(() => {
initService(!isRelaunch); initService(!isRelaunch);
}, 100); }, 100);
},[initService]); },
[initService]
);
const handleRelaunchEvent = useCallback(() => { const handleRelaunchEvent = useCallback(() => {
console.log("handleRelaunchEvent started"); console.log("handleRelaunchEvent started");
@@ -99,12 +115,25 @@ function AppBase(props) {
// set foreground flag using delay time. // set foreground flag using delay time.
clearTimeout(foreGroundChangeTimer); clearTimeout(foreGroundChangeTimer);
foreGroundChangeTimer = setTimeout(() => { foreGroundChangeTimer = setTimeout(() => {
console.log("visibility changed !!! ==> set to foreground cursorVisible", JSON.stringify(window.PalmSystem?.cursor?.visibility)); // eslint-disable-line no-console console.log(
"visibility changed !!! ==> set to foreground cursorVisible",
JSON.stringify(window.PalmSystem?.cursor?.visibility)
); // eslint-disable-line no-console
if (platform.platformName !== "webos") { if (platform.platformName !== "webos") {
//for debug //for debug
dispatch(changeAppStatus({ isAppForeground: true, cursorVisible: !platform.touchscreen })); dispatch(
} else if (typeof window === 'object') { changeAppStatus({
dispatch(changeAppStatus({ isAppForeground: true, cursorVisible: window.PalmSystem?.cursor?.visibility })); isAppForeground: true,
cursorVisible: !platform.touchscreen,
})
);
} else if (typeof window === "object") {
dispatch(
changeAppStatus({
isAppForeground: true,
cursorVisible: window.PalmSystem?.cursor?.visibility,
})
);
} }
}, 1000); }, 1000);
setTimeout(() => { setTimeout(() => {
@@ -116,14 +145,15 @@ function AppBase(props) {
useEffect(() => { useEffect(() => {
if (typeof window === "object" && window.PalmSystem) { if (typeof window === "object" && window.PalmSystem) {
window.PalmSystem.activate(); window.PalmSystem.activate();
window.lunaTest = (service, method, subscribe, parameters) => lunaTest(service, method, subscribe, parameters); window.lunaTest = (service, method, subscribe, parameters) =>
lunaTest(service, method, subscribe, parameters);
} }
handleLaunchEvent(); handleLaunchEvent();
document.addEventListener("visibilitychange", visibilityChanged); document.addEventListener("visibilitychange", visibilityChanged);
document.addEventListener("webOSRelaunch", handleRelaunchEvent); document.addEventListener("webOSRelaunch", handleRelaunchEvent);
return () => { return () => {
document.removeEventListener("visibilitychange", visibilityChanged) document.removeEventListener("visibilitychange", visibilityChanged);
document.removeEventListener("webOSRelaunch", handleRelaunchEvent) document.removeEventListener("webOSRelaunch", handleRelaunchEvent);
}; };
}, [dispatch]); }, [dispatch]);