diff --git a/ui/src/hooks/stores.ts b/ui/src/hooks/stores.ts index 95faeb46..85dca5d3 100644 --- a/ui/src/hooks/stores.ts +++ b/ui/src/hooks/stores.ts @@ -7,10 +7,6 @@ import { MAX_KEYS_PER_STEP, } from "@/constants/macros"; -import { devWarn } from '../utils/debug'; - - - // Define the JsonRpc types for better type checking interface JsonRpcResponse { jsonrpc: string; @@ -782,7 +778,7 @@ export const useNetworkStateStore = create((set, get) => ({ setDhcpLeaseExpiry: (expiry: Date) => { const lease = get().dhcp_lease; if (!lease) { - devWarn("No lease found"); + console.warn("No lease found"); return; } @@ -845,7 +841,7 @@ export const useMacrosStore = create((set, get) => ({ const { sendFn } = get(); if (!sendFn) { - // console.warn("JSON-RPC send function not available."); + console.warn("JSON-RPC send function not available."); return; } @@ -855,7 +851,7 @@ export const useMacrosStore = create((set, get) => ({ await new Promise((resolve, reject) => { sendFn("getKeyboardMacros", {}, (response: JsonRpcResponse) => { if (response.error) { - // console.error("Error loading macros:", response.error); + console.error("Error loading macros:", response.error); reject(new Error(response.error.message)); return; } @@ -879,8 +875,8 @@ export const useMacrosStore = create((set, get) => ({ resolve(); }); }); - } catch { - // console.error("Failed to load macros:", _error); + } catch (error) { + console.error("Failed to load macros:", error); } finally { set({ loading: false }); } @@ -889,20 +885,20 @@ export const useMacrosStore = create((set, get) => ({ saveMacros: async (macros: KeySequence[]) => { const { sendFn } = get(); if (!sendFn) { - // console.warn("JSON-RPC send function not available."); + console.warn("JSON-RPC send function not available."); throw new Error("JSON-RPC send function not available"); } if (macros.length > MAX_TOTAL_MACROS) { - // console.error(`Cannot save: exceeded maximum of ${MAX_TOTAL_MACROS} macros`); + console.error(`Cannot save: exceeded maximum of ${MAX_TOTAL_MACROS} macros`); throw new Error(`Cannot save: exceeded maximum of ${MAX_TOTAL_MACROS} macros`); } for (const macro of macros) { if (macro.steps.length > MAX_STEPS_PER_MACRO) { - // console.error( - // `Cannot save: macro "${macro.name}" exceeds maximum of ${MAX_STEPS_PER_MACRO} steps`, - // ); + console.error( + `Cannot save: macro "${macro.name}" exceeds maximum of ${MAX_STEPS_PER_MACRO} steps`, + ); throw new Error( `Cannot save: macro "${macro.name}" exceeds maximum of ${MAX_STEPS_PER_MACRO} steps`, ); @@ -911,9 +907,9 @@ export const useMacrosStore = create((set, get) => ({ for (let i = 0; i < macro.steps.length; i++) { const step = macro.steps[i]; if (step.keys && step.keys.length > MAX_KEYS_PER_STEP) { - // console.error( - // `Cannot save: macro "${macro.name}" step ${i + 1} exceeds maximum of ${MAX_KEYS_PER_STEP} keys`, - // ); + console.error( + `Cannot save: macro "${macro.name}" step ${i + 1} exceeds maximum of ${MAX_KEYS_PER_STEP} keys`, + ); throw new Error( `Cannot save: macro "${macro.name}" step ${i + 1} exceeds maximum of ${MAX_KEYS_PER_STEP} keys`, ); @@ -940,7 +936,7 @@ export const useMacrosStore = create((set, get) => ({ }); if (response.error) { - // console.error("Error saving macros:", response.error); + console.error("Error saving macros:", response.error); const errorMessage = typeof response.error.data === "string" ? response.error.data @@ -950,6 +946,9 @@ export const useMacrosStore = create((set, get) => ({ // Only update the store if the request was successful set({ macros: macrosWithSortOrder }); + } catch (error) { + console.error("Failed to save macros:", error); + throw error; } finally { set({ loading: false }); }