Compare commits

...

4 Commits

Author SHA1 Message Date
Marc Brooks f7918a0f6c
Merge 8e00b3d581 into 28919bf37c 2025-11-05 20:56:40 +00:00
Marc Brooks 8e00b3d581
Fix CoPilot complaints 2025-11-05 14:56:27 -06:00
Aveline 28919bf37c
fix: await sleep needs to be called inside async function (#946) 2025-11-05 13:25:13 -06:00
Marc Brooks 4090592112
chore: add delay before forced page-reload (#916) 2025-11-04 15:12:03 +01:00
4 changed files with 14 additions and 6 deletions

View File

@ -386,7 +386,7 @@ export class CancelKeyboardMacroReportMessage extends RpcMessage {
constructor(token: string) {
super(HID_RPC_MESSAGE_TYPES.CancelKeyboardMacroReport);
this.token = (token == null || token === undefined || token === "")
this.token = (token == null || token === "")
? "00000000-0000-0000-0000-000000000000"
: token;
}
@ -397,11 +397,11 @@ export class CancelKeyboardMacroReportMessage extends RpcMessage {
}
public static unmarshal(data: Uint8Array): CancelKeyboardMacroReportMessage | undefined {
if (data.length == 0) {
if (data.length === 0) {
return new CancelKeyboardMacroReportMessage("00000000-0000-0000-0000-000000000000");
}
if (data.length != 16) {
if (data.length !== 16) {
throw new Error(`Invalid cancel message length: ${data.length}`);
}

View File

@ -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,8 +312,10 @@ 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);
window.location.reload();
}}
/>

View File

@ -4,13 +4,16 @@ 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);
window.location.reload(); // force a full reload to ensure the current device/cloud UI version is loaded
}, [navigate]);

View File

@ -21,8 +21,10 @@ 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);
window.location.reload(); // force a full reload to ensure the current device/cloud UI version is loaded
}, [navigate]);