From 28919bf37c01a24082429b6107b35009263a992b Mon Sep 17 00:00:00 2001 From: Aveline <352441+ym@users.noreply.github.com> Date: Wed, 5 Nov 2025 20:25:13 +0100 Subject: [PATCH] fix: await sleep needs to be called inside async function (#946) --- ui/src/routes/devices.$id.settings.advanced.tsx | 3 ++- ui/src/routes/devices.$id.settings.general.reboot.tsx | 3 ++- ui/src/routes/devices.$id.settings.general.update.tsx | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ui/src/routes/devices.$id.settings.advanced.tsx b/ui/src/routes/devices.$id.settings.advanced.tsx index dbc98a75..4c3c9e94 100644 --- a/ui/src/routes/devices.$id.settings.advanced.tsx +++ b/ui/src/routes/devices.$id.settings.advanced.tsx @@ -12,6 +12,7 @@ import { TextAreaWithLabel } from "@components/TextArea"; import { isOnDevice } from "@/main"; import notifications from "@/notifications"; import { m } from "@localizations/messages.js"; +import { sleep } from "@/utils"; export default function SettingsAdvancedRoute() { const { send } = useJsonRpc(); @@ -311,7 +312,7 @@ export default function SettingsAdvancedRoute() { size="SM" theme="light" text={m.advanced_reset_config_button()} - onClick={() => { + onClick={async () => { handleResetConfig(); // Add 2s delay between resetting the configuration and calling reload() to prevent reload from interrupting the RPC call to reset things. await sleep(2000); diff --git a/ui/src/routes/devices.$id.settings.general.reboot.tsx b/ui/src/routes/devices.$id.settings.general.reboot.tsx index 5a4474e6..fc0feeaa 100644 --- a/ui/src/routes/devices.$id.settings.general.reboot.tsx +++ b/ui/src/routes/devices.$id.settings.general.reboot.tsx @@ -4,12 +4,13 @@ import { useNavigate } from "react-router"; import { useJsonRpc } from "@hooks/useJsonRpc"; import { Button } from "@components/Button"; import { m } from "@localizations/messages.js"; +import { sleep } from "@/utils"; export default function SettingsGeneralRebootRoute() { const navigate = useNavigate(); const { send } = useJsonRpc(); - const onClose = useCallback(() => { + const onClose = useCallback(async () => { navigate(".."); // back to the devices.$id.settings page // Add 1s delay between navigation and calling reload() to prevent reload from interrupting the navigation. await sleep(1000); diff --git a/ui/src/routes/devices.$id.settings.general.update.tsx b/ui/src/routes/devices.$id.settings.general.update.tsx index 3a52eee2..285ce940 100644 --- a/ui/src/routes/devices.$id.settings.general.update.tsx +++ b/ui/src/routes/devices.$id.settings.general.update.tsx @@ -21,7 +21,7 @@ export default function SettingsGeneralUpdateRoute() { const { setModalView, otaState } = useUpdateStore(); const { send } = useJsonRpc(); - const onClose = useCallback(() => { + const onClose = useCallback(async () => { navigate(".."); // back to the devices.$id.settings page // Add 1s delay between navigation and calling reload() to prevent reload from interrupting the navigation. await sleep(1000);