From 0592695f1fc11eee3e9d23708468aca047c334c5 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Fri, 7 Feb 2025 17:57:27 +0900 Subject: [PATCH] [Update] Add network error notification. --- src-ui/logics/common/index.js | 3 ++- .../logics/common/useHandleNetworkConnection.js | 16 ++++++++++++++++ src-ui/logics/useReceiveRoutes.js | 5 ++++- 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 src-ui/logics/common/useHandleNetworkConnection.js diff --git a/src-ui/logics/common/index.js b/src-ui/logics/common/index.js index e63b28db..8f160826 100644 --- a/src-ui/logics/common/index.js +++ b/src-ui/logics/common/index.js @@ -9,4 +9,5 @@ export { useNotificationStatus } from "./useNotificationStatus"; export { useOpenFolder } from "./useOpenFolder"; export { useMessage } from "./useMessage"; export { useUpdateSoftware } from "./useUpdateSoftware"; -export { useVolume } from "./useVolume"; \ No newline at end of file +export { useVolume } from "./useVolume"; +export { useHandleNetworkConnection } from "./useHandleNetworkConnection"; \ No newline at end of file diff --git a/src-ui/logics/common/useHandleNetworkConnection.js b/src-ui/logics/common/useHandleNetworkConnection.js new file mode 100644 index 00000000..9c1d1f8c --- /dev/null +++ b/src-ui/logics/common/useHandleNetworkConnection.js @@ -0,0 +1,16 @@ +import { useNotificationStatus } from "@logics_common"; + +export const useHandleNetworkConnection = () => { + + const { showNotification_Error } = useNotificationStatus(); + + const handleNetworkConnection = (is_network_connected) => { + if (!is_network_connected) { + showNotification_Error("Network is not connected. Some of the function will not work."); + } + }; + + return { + handleNetworkConnection, + }; +}; \ No newline at end of file diff --git a/src-ui/logics/useReceiveRoutes.js b/src-ui/logics/useReceiveRoutes.js index 030a199b..3e47507f 100644 --- a/src-ui/logics/useReceiveRoutes.js +++ b/src-ui/logics/useReceiveRoutes.js @@ -3,7 +3,7 @@ import { arrayToObject } from "@utils"; import { useNotificationStatus, - + useHandleNetworkConnection, useComputeMode, useInitProgress, @@ -178,6 +178,8 @@ export const useReceiveRoutes = () => { const { showNotification_Success, showNotification_Error } = useNotificationStatus(); + const { handleNetworkConnection } = useHandleNetworkConnection(); + const routes = { // Common "/run/feed_watchdog": () => {}, @@ -188,6 +190,7 @@ export const useReceiveRoutes = () => { "/run/open_filepath_logs": () => console.log("Opened Directory, Message Logs"), "/run/open_filepath_config_file": () => console.log("Opened Directory, Config File"), "/run/update_software_flag": updateIsSoftwareUpdateAvailable, + "/run/connected_network": handleNetworkConnection, // Main Page // Page Controls