From b3e1890c9d3cb9085d9551342f3f9908d4d92aa2 Mon Sep 17 00:00:00 2001 From: "hyunwoo93.cha" Date: Mon, 13 Jan 2025 16:03:47 +0900 Subject: [PATCH] =?UTF-8?q?[SHOPTIME-3325]=20=EC=95=B1=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=ED=9B=84=20=EC=9E=AC=EC=84=A4=EC=B9=98=20=EC=8B=9C?= =?UTF-8?q?=20=EA=B3=BC=EA=B1=B0=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=9C=A0?= =?UTF-8?q?=EC=A7=80=EB=90=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 수정 내용: db8로 앱 첫실행 유무 flag 추가. --- com.twin.app.shoptime/src/App/App.js | 11 +++- .../src/actions/appDataActions.js | 22 ++++++++ com.twin.app.shoptime/src/lunaSend/common.js | 52 +++++++++++++++++++ .../src/reducers/appDataReducer.js | 13 +++++ 4 files changed, 96 insertions(+), 2 deletions(-) diff --git a/com.twin.app.shoptime/src/App/App.js b/com.twin.app.shoptime/src/App/App.js index ddb6733d..4831cc91 100644 --- a/com.twin.app.shoptime/src/App/App.js +++ b/com.twin.app.shoptime/src/App/App.js @@ -15,6 +15,7 @@ import Spotlight from "@enact/spotlight"; import appinfo from "../../webos-meta/appinfo.json"; import { types } from "../actions/actionTypes"; +import { checkAppFirstLaunch } from "../actions/appDataActions"; import { changeAppStatus, deleteOldDb8Datas, @@ -132,6 +133,10 @@ function AppBase(props) { const oldDb8Deleted = useSelector( (state) => state.localSettings.oldDb8Deleted ); + const isFirstLaunch = useSelector((state) => state.appData.isFirstLaunch); + const isFirstLaunchChecked = useSelector( + (state) => state.appData.isFirstLaunchChecked + ); const deviceCountryCode = httpHeader?.["X-Device-Country"] || ""; @@ -150,10 +155,10 @@ function AppBase(props) { }, [logEnable]); useEffect(() => { - if (!oldDb8Deleted) { + if (!oldDb8Deleted && !isFirstLaunch && isFirstLaunchChecked) { dispatch(deleteOldDb8Datas()); } - }, [oldDb8Deleted]); + }, [oldDb8Deleted, isFirstLaunch, isFirstLaunchChecked]); const hideCursor = useRef( new Job((func) => { @@ -267,6 +272,8 @@ function AppBase(props) { window.PalmSystem.activate(); window.lunaTest = (service, method, subscribe, parameters) => lunaTest(service, method, subscribe, parameters); + + dispatch(checkAppFirstLaunch()); } dispatch(getDeviceId()); diff --git a/com.twin.app.shoptime/src/actions/appDataActions.js b/com.twin.app.shoptime/src/actions/appDataActions.js index 3c21616f..c7efeadd 100644 --- a/com.twin.app.shoptime/src/actions/appDataActions.js +++ b/com.twin.app.shoptime/src/actions/appDataActions.js @@ -1,5 +1,6 @@ import { URLS } from "../api/apiConfig"; import { TAxios } from "../api/TAxios"; +import * as lunaSend from "../lunaSend"; import { types } from "./actionTypes"; export const addMainIndex = (index) => ({ @@ -65,3 +66,24 @@ export const sendSms = (params) => (dispatch, getState) => { export const clearSMS = () => ({ type: types.CLEAR_SMS, }); + +export const checkAppFirstLaunch = () => (dispatch) => { + lunaSend.checkFirstLaunch({ + onSuccess: (res) => { + const isFirstLaunch = res.results.length === 0; + dispatch({ + type: types.CHECK_FIRST_LAUNCH, + payload: isFirstLaunch, + isFirstLaunchChecked: true, + }); + + if (isFirstLaunch) { + lunaSend.setFirstLaunch({ + onSuccess: () => { + dispatch({ type: types.SET_FIRST_LAUNCH }); + }, + }); + } + }, + }); +}; diff --git a/com.twin.app.shoptime/src/lunaSend/common.js b/com.twin.app.shoptime/src/lunaSend/common.js index 5c5c0539..727a2d41 100644 --- a/com.twin.app.shoptime/src/lunaSend/common.js +++ b/com.twin.app.shoptime/src/lunaSend/common.js @@ -319,3 +319,55 @@ export const deleteOldDb8 = (kind, { onSuccess, onFailure, onComplete }) => { onComplete, }); }; + +export const checkFirstLaunch = ({ onSuccess, onFailure, onComplete }) => { + if (typeof window === "object" && !window.PalmSystem) { + console.log("LUNA SEND checkFirstLaunch"); + onSuccess({ results: [] }); + return; + } + + return new LS2Request().send({ + service: "luna://com.webos.service.db", + method: "find", + parameters: { + query: { + from: "com.shoptime.app.settings:1", + where: [ + { + prop: "usedApp", + op: "=", + val: true, + }, + ], + }, + }, + onSuccess, + onFailure, + onComplete, + }); +}; + +export const setFirstLaunch = ({ onSuccess, onFailure, onComplete }) => { + if (typeof window === "object" && !window.PalmSystem) { + console.log("LUNA SEND setFirstLaunch"); + onSuccess(); + return; + } + + return new LS2Request().send({ + service: "luna://com.webos.service.db", + method: "put", + parameters: { + objects: [ + { + _kind: "com.shoptime.app.settings:1", + usedApp: true, + }, + ], + }, + onSuccess, + onFailure, + onComplete, + }); +}; diff --git a/com.twin.app.shoptime/src/reducers/appDataReducer.js b/com.twin.app.shoptime/src/reducers/appDataReducer.js index 82bf1a85..0c1c6f6f 100644 --- a/com.twin.app.shoptime/src/reducers/appDataReducer.js +++ b/com.twin.app.shoptime/src/reducers/appDataReducer.js @@ -3,6 +3,8 @@ import { types } from "../actions/actionTypes"; const initialState = { mainIndex: null, sendSms: {}, + isFirstLaunch: null, + isFirstLaunchChecked: false, }; export const appDataReducer = (state = initialState, action) => { @@ -22,6 +24,17 @@ export const appDataReducer = (state = initialState, action) => { ...state, sendSms: { retCode: undefined }, }; + case types.CHECK_FIRST_LAUNCH: + return { + ...state, + isFirstLaunch: action.payload, + isFirstLaunchChecked: action.isFirstLaunchChecked, + }; + case types.SET_FIRST_LAUNCH: + return { + ...state, + isFirstLaunch: false, + }; default: return state; }