(key: keyof SettingsState, oldVal: string, newVal: string, cb: () => void)
| 42 | useEffect(() => { isEnabled().then(v => set("autoStart", v)).catch(() => { }); }, []); |
| 43 | |
| 44 | async function changeShortcut(key: keyof SettingsState, oldVal: string, newVal: string, cb: () => void) { |
| 45 | if (oldVal) await unregister(oldVal).catch(() => { }); |
| 46 | if (newVal) { |
| 47 | try { |
| 48 | await register(newVal, cb); |
| 49 | notify(t("settings.registerSuccess", { shortcut: newVal }), "success"); |
| 50 | } catch { |
| 51 | notify(t("settings.registerFail", { shortcut: newVal }), "error"); |
| 52 | } |
| 53 | } |
| 54 | await set(key as keyof SettingsState, newVal); |
| 55 | } |
| 56 | |
| 57 | if (!settings) { |
| 58 | return <Box sx={{ flex: 1, display: "flex", alignItems: "center", justifyContent: "center" }}> |
no test coverage detected