[지라이슈없음] network status check (develop progress)

This commit is contained in:
hyunwoo93.cha
2025-01-22 16:29:48 +09:00
parent d876f29c8e
commit 5853b29696
3 changed files with 48 additions and 0 deletions

View File

@@ -133,9 +133,14 @@ function AppBase(props) {
const oldDb8Deleted = useSelector(
(state) => state.localSettings.oldDb8Deleted
);
const isInternetConnected = useSelector(
(state) => state.common.appStatus.isInternetConnected
);
const deviceCountryCode = httpHeader?.["X-Device-Country"] || "";
useEffect(() => {});
useEffect(() => {
if (!cursorVisible && !Spotlight.getCurrent()) {
Spotlight.focus();

View File

@@ -1,3 +1,4 @@
import { Job } from "@enact/core/util";
import Spotlight from "@enact/spotlight";
import appinfo from "../../webos-meta/appinfo.json";
@@ -555,3 +556,44 @@ export const checkFirstLaunch = () => (dispatch) => {
},
});
};
let updateNetworkStateJob = new Job((dispatch, connected) => {
dispatch(changeAppStatus({ isInternetConnected: connected }));
});
export const getConnectionStatus = () => (dispatch, getState) => {
lunaSend.getConnectionStatus({
onSuccess: (res) => {
console.log("lunasend getConnectionStatus", res);
if (res.returnValue) {
const isInternet =
(res.wifi && res.wifi.onInternet === "yes") ||
(res.wired && res.wired.onInternet === "yes");
const isInternetConnected =
(res.wifi && res.wifi.state === "connected") ||
(res.wired && res.wired.state === "connected");
console.log(
"internetconnected.............",
isInternet,
isInternetConnected,
res
);
const connected = isInternet && isInternetConnected;
updateNetworkStateJob.startAfter(
connected ? 100 : 3000,
dispatch,
connected
);
}
},
onFailure: (err) => {
console.log(err);
},
onComplete: (res) => {
console.log("getConnectionStatus done", res);
},
});
};

View File

@@ -14,6 +14,7 @@ const initialState = {
toast: false,
toastText: null,
captionEnable: false,
isInternetConnected: true,
},
broadcast: {},
httpHeader: null,