[App] dispatch 추가
Detail Notes : 1. getOnSaleInfo를 통한 api 데이터의 범용성으로 App.js 이동
This commit is contained in:
@@ -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 { getBrandList } from '../actions/brandActions';
|
||||
import { getAuthenticationCode } from '../actions/deviceActions';
|
||||
import platform from "@enact/core/platform";
|
||||
import ThemeDecorator from "@enact/sandstone/ThemeDecorator";
|
||||
|
||||
import appinfo from "../../webos-meta/appinfo.json";
|
||||
import { getBrandList } from "../actions/brandActions";
|
||||
import { changeAppStatus } from "../actions/commonActions";
|
||||
import { getAuthenticationCode } from "../actions/deviceActions";
|
||||
import {
|
||||
getHomeLayout,
|
||||
getHomeMainContents,
|
||||
getHomeMenu,
|
||||
getThemeCurationInfo,
|
||||
} from '../actions/homeActions';
|
||||
import {
|
||||
getSubCategory,
|
||||
getTop20Show,
|
||||
} from '../actions/mainActions';
|
||||
import { getMyRecommandedKeyword } from '../actions/myPageActions';
|
||||
import { getBestSeller } from '../actions/productActions';
|
||||
import MainView from '../views/MainView/MainView';
|
||||
} from "../actions/homeActions";
|
||||
import { getSubCategory, getTop20Show } from "../actions/mainActions";
|
||||
import { getMyRecommandedKeyword } from "../actions/myPageActions";
|
||||
import { getOnSaleInfo } from "../actions/onSaleActions";
|
||||
import { getBestSeller } from "../actions/productActions";
|
||||
import { lunaTest } from "../lunaSend/lunaTest";
|
||||
import appinfo from '../../webos-meta/appinfo.json';
|
||||
import css from './App.module.less';
|
||||
import { getLaunchParams } from '../utils/helperMethods';
|
||||
import { changeAppStatus } from '../actions/commonActions';
|
||||
import { handleDeepLink } from './deepLinkHandler';
|
||||
import { getLaunchParams } from "../utils/helperMethods";
|
||||
import MainView from "../views/MainView/MainView";
|
||||
import css from "./App.module.less";
|
||||
import { handleDeepLink } from "./deepLinkHandler";
|
||||
|
||||
let foreGroundChangeTimer = null;
|
||||
|
||||
@@ -33,11 +32,19 @@ function AppBase(props) {
|
||||
|
||||
const initService = useCallback(
|
||||
(haveyInit = true) => {
|
||||
console.log( "<<<<<<<<<<<<< appinfo >>>>>>>>>>>>{heavyInit, appinfo} ", haveyInit, appinfo);
|
||||
console.log(
|
||||
"<<<<<<<<<<<<< appinfo >>>>>>>>>>>>{heavyInit, appinfo} ",
|
||||
haveyInit,
|
||||
appinfo
|
||||
);
|
||||
if (haveyInit) {
|
||||
dispatch(changeAppStatus({ connectionFailed: false }));
|
||||
if (typeof window === "object" && window.PalmSystem) {
|
||||
dispatch(changeAppStatus({ cursorVisible: window.PalmSystem?.cursor?.visibility }));
|
||||
dispatch(
|
||||
changeAppStatus({
|
||||
cursorVisible: window.PalmSystem?.cursor?.visibility,
|
||||
})
|
||||
);
|
||||
}
|
||||
//todo
|
||||
// dispatch(getSystemSettings());
|
||||
@@ -48,6 +55,7 @@ function AppBase(props) {
|
||||
// dispatch(getHttpHeaderForServiceRequest(webOSVersion, language));
|
||||
|
||||
dispatch(getAuthenticationCode());
|
||||
dispatch(getOnSaleInfo({ categoryIncFlag: "Y", lgCatCd: "" }));
|
||||
dispatch(getHomeMenu());
|
||||
dispatch(getHomeLayout());
|
||||
dispatch(getHomeMainContents());
|
||||
@@ -67,14 +75,20 @@ function AppBase(props) {
|
||||
dispatch(getThemeCurationInfo());
|
||||
}
|
||||
},
|
||||
[dispatch]);
|
||||
[dispatch]
|
||||
);
|
||||
|
||||
const handleLaunchEvent = useCallback((isRelaunch=false)=>{
|
||||
const handleLaunchEvent = useCallback(
|
||||
(isRelaunch = false) => {
|
||||
//todo deeplink
|
||||
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
|
||||
dispatch(handleDeepLink(launchParams.contentTarget));
|
||||
}
|
||||
@@ -82,7 +96,9 @@ function AppBase(props) {
|
||||
setTimeout(() => {
|
||||
initService(!isRelaunch);
|
||||
}, 100);
|
||||
},[initService]);
|
||||
},
|
||||
[initService]
|
||||
);
|
||||
|
||||
const handleRelaunchEvent = useCallback(() => {
|
||||
console.log("handleRelaunchEvent started");
|
||||
@@ -99,12 +115,25 @@ function AppBase(props) {
|
||||
// set foreground flag using delay time.
|
||||
clearTimeout(foreGroundChangeTimer);
|
||||
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") {
|
||||
//for debug
|
||||
dispatch(changeAppStatus({ isAppForeground: true, cursorVisible: !platform.touchscreen }));
|
||||
} else if (typeof window === 'object') {
|
||||
dispatch(changeAppStatus({ isAppForeground: true, cursorVisible: window.PalmSystem?.cursor?.visibility }));
|
||||
dispatch(
|
||||
changeAppStatus({
|
||||
isAppForeground: true,
|
||||
cursorVisible: !platform.touchscreen,
|
||||
})
|
||||
);
|
||||
} else if (typeof window === "object") {
|
||||
dispatch(
|
||||
changeAppStatus({
|
||||
isAppForeground: true,
|
||||
cursorVisible: window.PalmSystem?.cursor?.visibility,
|
||||
})
|
||||
);
|
||||
}
|
||||
}, 1000);
|
||||
setTimeout(() => {
|
||||
@@ -116,14 +145,15 @@ function AppBase(props) {
|
||||
useEffect(() => {
|
||||
if (typeof window === "object" && window.PalmSystem) {
|
||||
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();
|
||||
document.addEventListener("visibilitychange", visibilityChanged);
|
||||
document.addEventListener("webOSRelaunch", handleRelaunchEvent);
|
||||
return () => {
|
||||
document.removeEventListener("visibilitychange", visibilityChanged)
|
||||
document.removeEventListener("webOSRelaunch", handleRelaunchEvent)
|
||||
document.removeEventListener("visibilitychange", visibilityChanged);
|
||||
document.removeEventListener("webOSRelaunch", handleRelaunchEvent);
|
||||
};
|
||||
}, [dispatch]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user