From cc6bcd225b4365d036538cc776b516bdcfe7f60e Mon Sep 17 00:00:00 2001 From: "hyunwoo93.cha" Date: Wed, 15 Jan 2025 16:42:28 +0900 Subject: [PATCH] =?UTF-8?q?[SHOPTIME-3324]=20=EC=95=BD=EA=B4=80=20?= =?UTF-8?q?=EC=B2=A0=ED=9A=8C=20=ED=9B=84=20=EC=9E=AC=EB=8F=99=EC=9D=98=20?= =?UTF-8?q?=EC=8B=9C=20=EA=B3=BC=EA=B1=B0=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EC=9C=A0=EC=A7=80=EB=90=98=EB=8A=94=20=ED=98=84=EC=83=81=20[SH?= =?UTF-8?q?OPTIME-3325]=20=EC=95=B1=20=EC=82=AD=EC=A0=9C=20=ED=9B=84=20?= =?UTF-8?q?=EC=9E=AC=EC=84=A4=EC=B9=98=20=EC=8B=9C=20=EA=B3=BC=EA=B1=B0=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=9C=A0=EC=A7=80=EB=90=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit lunaSend db8 추가 (테스트 필요) --- com.twin.app.shoptime/src/App/App.js | 3 ++ .../src/actions/commonActions.js | 37 +++++++++++++++ com.twin.app.shoptime/src/lunaSend/common.js | 47 +++++++++++++++++++ 3 files changed, 87 insertions(+) diff --git a/com.twin.app.shoptime/src/App/App.js b/com.twin.app.shoptime/src/App/App.js index ddb6733d..f18fbe12 100644 --- a/com.twin.app.shoptime/src/App/App.js +++ b/com.twin.app.shoptime/src/App/App.js @@ -17,6 +17,7 @@ import appinfo from "../../webos-meta/appinfo.json"; import { types } from "../actions/actionTypes"; import { changeAppStatus, + checkFirstLaunch, deleteOldDb8Datas, getDeviceId, getHttpHeaderForServiceRequest, @@ -309,6 +310,8 @@ function AppBase(props) { }) ); } + dispatch(checkFirstLaunch()); + dispatch( getHomeTerms({ mbrNo: loginUserData.userNumber, diff --git a/com.twin.app.shoptime/src/actions/commonActions.js b/com.twin.app.shoptime/src/actions/commonActions.js index a1e7f0a9..bfbfb011 100644 --- a/com.twin.app.shoptime/src/actions/commonActions.js +++ b/com.twin.app.shoptime/src/actions/commonActions.js @@ -4,6 +4,7 @@ import appinfo from "../../webos-meta/appinfo.json"; import appinfo35 from "../../webos-meta/appinfo35.json"; import appinfo79 from "../../webos-meta/appinfo79.json"; import * as lunaSend from "../lunaSend"; +import { initialLocalSettings } from "../reducers/localSettingsReducer"; import * as Config from "../utils/Config"; import { types } from "./actionTypes"; @@ -508,3 +509,39 @@ export const deleteOldDb8Datas = () => (dispatch) => { } dispatch(changeLocalSettings({ oldDb8Deleted: true })); }; + +export const checkFirstLaunch = () => (dispatch) => { + lunaSend.checkFirstLaunch({ + onSuccess: (res) => { + if (!res.returnValue) { + console.error("Failed to check first launch status"); + return; + } + + if (res.results.length === 0) { + console.log("First launch detected - initializing localStorage"); + + if (typeof window === "object") { + dispatch(changeLocalSettings(initialLocalSettings)); + } + + lunaSend.saveFirstLaunchInfo({ + onSuccess: (saveRes) => { + console.log("First launch info saved to DB8:", saveRes); + dispatch(changeAppStatus({ isFirstLaunch: true })); + }, + onFailure: (err) => { + console.error("Failed to save first launch info:", err); + }, + }); + } else { + console.log("Not first launch - keeping existing settings"); + + dispatch(changeAppStatus({ isFirstLaunch: false })); + } + }, + onFailure: (err) => { + console.error("Failed to check first launch:", err); + }, + }); +}; diff --git a/com.twin.app.shoptime/src/lunaSend/common.js b/com.twin.app.shoptime/src/lunaSend/common.js index 5c5c0539..4420daab 100644 --- a/com.twin.app.shoptime/src/lunaSend/common.js +++ b/com.twin.app.shoptime/src/lunaSend/common.js @@ -319,3 +319,50 @@ 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"); + return; + } + + return new LS2Request().send({ + service: "luna://com.webos.service.db", + method: "find", + parameters: { + query: { + from: `${appinfo.id}:1`, + where: [{ prop: "type", op: "=", val: "app_init" }], + }, + }, + onSuccess, + onFailure, + onComplete, + }); +}; + +export const saveFirstLaunchInfo = ({ onSuccess, onFailure, onComplete }) => { + if (typeof window === "object" && !window.PalmSystem) { + console.log("LUNA SEND saveFirstLaunchInfo"); + onSuccess({ returnValue: true }); + return; + } + + return new LS2Request().send({ + service: "luna://com.webos.service.db", + method: "put", + parameters: { + object: [ + { + _kind: `${appinfo.id}:1`, + type: "app_init", + initialized: true, + timestamp: new Date().toISOString(), + }, + ], + }, + onSuccess, + onFailure, + onComplete, + }); +};