Skip to content

Commit 28919bf

Browse files
authored
fix: await sleep needs to be called inside async function (#946)
1 parent 4090592 commit 28919bf

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

ui/src/routes/devices.$id.settings.advanced.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { TextAreaWithLabel } from "@components/TextArea";
1212
import { isOnDevice } from "@/main";
1313
import notifications from "@/notifications";
1414
import { m } from "@localizations/messages.js";
15+
import { sleep } from "@/utils";
1516

1617
export default function SettingsAdvancedRoute() {
1718
const { send } = useJsonRpc();
@@ -311,7 +312,7 @@ export default function SettingsAdvancedRoute() {
311312
size="SM"
312313
theme="light"
313314
text={m.advanced_reset_config_button()}
314-
onClick={() => {
315+
onClick={async () => {
315316
handleResetConfig();
316317
// Add 2s delay between resetting the configuration and calling reload() to prevent reload from interrupting the RPC call to reset things.
317318
await sleep(2000);

ui/src/routes/devices.$id.settings.general.reboot.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import { useNavigate } from "react-router";
44
import { useJsonRpc } from "@hooks/useJsonRpc";
55
import { Button } from "@components/Button";
66
import { m } from "@localizations/messages.js";
7+
import { sleep } from "@/utils";
78

89
export default function SettingsGeneralRebootRoute() {
910
const navigate = useNavigate();
1011
const { send } = useJsonRpc();
1112

12-
const onClose = useCallback(() => {
13+
const onClose = useCallback(async () => {
1314
navigate(".."); // back to the devices.$id.settings page
1415
// Add 1s delay between navigation and calling reload() to prevent reload from interrupting the navigation.
1516
await sleep(1000);

ui/src/routes/devices.$id.settings.general.update.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default function SettingsGeneralUpdateRoute() {
2121
const { setModalView, otaState } = useUpdateStore();
2222
const { send } = useJsonRpc();
2323

24-
const onClose = useCallback(() => {
24+
const onClose = useCallback(async () => {
2525
navigate(".."); // back to the devices.$id.settings page
2626
// Add 1s delay between navigation and calling reload() to prevent reload from interrupting the navigation.
2727
await sleep(1000);

0 commit comments

Comments
 (0)