diff --git a/com.twin.app.shoptime/src/App/App.js b/com.twin.app.shoptime/src/App/App.js index e2c78f40..15121375 100644 --- a/com.twin.app.shoptime/src/App/App.js +++ b/com.twin.app.shoptime/src/App/App.js @@ -12,6 +12,7 @@ import { changeAppStatus, checkFirstLaunch, deleteOldDb8Datas, + getConnectionInfo, getConnectionStatus, getDeviceId, getHttpHeaderForServiceRequest, @@ -21,7 +22,6 @@ import { setGNBMenu, setSecondLayerInfo, } from "../actions/commonActions"; -import { getConnectionInfo } from "../actions/deviceActions"; import { getShoptimeTerms } from "../actions/empActions"; import { getHomeMenu, getHomeTerms } from "../actions/homeActions"; import { @@ -124,7 +124,7 @@ function AppBase(props) { const oldDb8Deleted = useSelector( (state) => state.localSettings.oldDb8Deleted ); - const macAddress = useSelector((state) => state.device); + const macAddress = useSelector((state) => state.common.macAddress); const deviceCountryCode = httpHeader?.["X-Device-Country"] || ""; @@ -134,13 +134,13 @@ function AppBase(props) { } }, [cursorVisible]); - // useEffect(() => { - // if (logEnable) { - // enableConsole(); - // } else { - // disableConsole(); - // } - // }, [logEnable]); + useEffect(() => { + if (logEnable) { + enableConsole(); + } else { + disableConsole(); + } + }, [logEnable]); useEffect(() => { if (!oldDb8Deleted) { @@ -263,13 +263,10 @@ function AppBase(props) { } dispatch(getConnectionStatus()); + dispatch(getConnectionInfo()); dispatch(getDeviceId()); dispatch(getHttpHeaderForServiceRequest()); dispatch(getSystemSettings()); - - if (window.webOSSystem) { - dispatch(getConnectionInfo()); - } document.addEventListener("visibilitychange", visibilityChanged); document.addEventListener("webOSRelaunch", handleRelaunchEvent); //local virtual cursorvisiblilty @@ -287,7 +284,7 @@ function AppBase(props) { document.removeEventListener("wheel", mouseMoveEvent); } }; - }, []); + }, [dispatch]); useEffect(() => { let userDataChanged = false; diff --git a/com.twin.app.shoptime/src/actions/actionTypes.js b/com.twin.app.shoptime/src/actions/actionTypes.js index 125cce91..1af279e4 100644 --- a/com.twin.app.shoptime/src/actions/actionTypes.js +++ b/com.twin.app.shoptime/src/actions/actionTypes.js @@ -10,7 +10,6 @@ export const types = { REGISTER_DEVICE: "REGISTER_DEVICE", REGISTER_DEVICE_INFO: "REGISTER_DEVICE_INFO", GET_DEVICE_INFO: "GET_DEVICE_INFO", - GET_DEVICE_MACADDRESS: "GET_DEVICE_ADDRESS", CLEAR_REGISTER_DEVICE_INFO: "CLEAR_REGISTER_DEVICE_INFO", // common actions @@ -34,6 +33,7 @@ export const types = { SET_SECOND_LAYER_INFO: "SET_SECOND_LAYER_INFO", SET_ERROR_MESSAGE: "SET_ERROR_MESSAGE", CLEAR_ERROR_MESSAGE: "CLEAR_ERROR_MESSAGE", + GET_DEVICE_MACADDRESS: "GET_DEVICE_MACADDRESS", // billing actions GET_MY_INFO_BILLING_SEARCH: "GET_MY_INFO_BILLING_SEARCH", diff --git a/com.twin.app.shoptime/src/actions/commonActions.js b/com.twin.app.shoptime/src/actions/commonActions.js index edcaa396..a9ff0fe0 100644 --- a/com.twin.app.shoptime/src/actions/commonActions.js +++ b/com.twin.app.shoptime/src/actions/commonActions.js @@ -596,6 +596,29 @@ export const getConnectionStatus = () => (dispatch, getState) => { }); }; +// macAddress +export const getConnectionInfo = () => (dispatch, getState) => { + lunaSend.getConnectionInfo({ + onSuccess: (res) => { + console.log("lunasend getConnectionStatus", res); + if (res && res.retrunValue) { + const macAddress = res?.wiredInfo.macAddress; + console.log("macAddress...........", macAddress, res); + } + }, + onFailure: (err) => { + console.log("getConnentionInfo", err); + }, + onComplete: (res) => { + console.log("getConnentionInfo done", res); + dispatch({ + type: types.GET_DEVICE_MACADDRESS, + payload: res, + }); + }, + }); +}; + export const disableNotification = () => (dispatch, getState) => { lunaSend.disableNotification({ onSuccess: (res) => { diff --git a/com.twin.app.shoptime/src/actions/deviceActions.js b/com.twin.app.shoptime/src/actions/deviceActions.js index 0e293a12..17478af2 100644 --- a/com.twin.app.shoptime/src/actions/deviceActions.js +++ b/com.twin.app.shoptime/src/actions/deviceActions.js @@ -153,25 +153,6 @@ export const getReAuthenticationCode = () => (dispatch, getState) => { ); }; -// macAddress -export const getConnectionInfo = () => (dispatch, getState) => { - lunaSend.getConnectionInfo({ - onSuccess: (res) => { - if (res && res.retrunValue) { - console.log("getConnentionInfo", res); - const macAddress = res?.wiredInfo.macAddress; - dispatch({ - type: types.GET_DEVICE_MACADDRESS, - payload: macAddress, - }); - } - }, - onFailure: (err) => { - console.log("getConnentionInfo", err); - }, - }); -}; - export const clearRegisterDeviceInfo = () => ({ type: types.CLEAR_REGISTER_DEVICE_INFO, }); diff --git a/com.twin.app.shoptime/src/lunaSend/common.js b/com.twin.app.shoptime/src/lunaSend/common.js index fa905743..1c879ccf 100644 --- a/com.twin.app.shoptime/src/lunaSend/common.js +++ b/com.twin.app.shoptime/src/lunaSend/common.js @@ -422,9 +422,9 @@ export const enableNotification = ({ onSuccess, onFailure, onComplete }) => { }; export const getConnectionInfo = ({ onSuccess, onFailure, onComplete }) => { - if (process.env.REACT_APP_MODE === "DEBUG") { - console.log("LUNA SEND getConnectionInfo"); - return "Some Hard Coded Mock Data"; + if (typeof window === "object" && !window.PalmSystem) { + console.log("LUNA SEND disableConnectionInfo"); + return; } else { return new LS2Request().send({ service: "luna://com.webos.service.connectionmanager", diff --git a/com.twin.app.shoptime/src/reducers/commonReducer.js b/com.twin.app.shoptime/src/reducers/commonReducer.js index 90a0ebda..640c0b90 100644 --- a/com.twin.app.shoptime/src/reducers/commonReducer.js +++ b/com.twin.app.shoptime/src/reducers/commonReducer.js @@ -69,6 +69,7 @@ const initialState = { }, secondLayerInfo: {}, + macAddress: { wifi: "", wired: "", p2p: "" }, }; export const commonReducer = (state = initialState, action) => { @@ -259,6 +260,16 @@ export const commonReducer = (state = initialState, action) => { secondLayerInfo: action.payload, }; } + case types.GET_DEVICE_MACADDRESS: { + return { + ...state, + macAddress: { + wifi: action.payload.wifiInfo.macAddress, + wired: action.payload.wiredInfo.macAddress, + p2p: action.payload.p2pInfo.macAddress, + }, + }; + } default: return state; diff --git a/com.twin.app.shoptime/src/reducers/deviceReducer.js b/com.twin.app.shoptime/src/reducers/deviceReducer.js index 983e9ba0..1f443e27 100644 --- a/com.twin.app.shoptime/src/reducers/deviceReducer.js +++ b/com.twin.app.shoptime/src/reducers/deviceReducer.js @@ -1,7 +1,6 @@ import { types } from "../actions/actionTypes"; const initialState = { - macAddress: { wifi: "", wired: "", p2p: "" }, regDeviceData: {}, regDeviceInfoData: {}, }; @@ -23,11 +22,6 @@ export const deviceReducer = (state = initialState, action) => { ...state, deviceInfo: action.payload.data.dvcInfo, }; - case types.GET_DEVICE_MACADDRESS: - return { - ...state, - macAddress: action, - }; case types.CLEAR_REGISTER_DEVICE_INFO: return { ...state,