MCPcopy
hub / github.com/game1024/OpenSpeedy / changeShortcut

Function changeShortcut

src/components/SettingsManager.tsx:44–55  ·  view source on GitHub ↗
(key: keyof SettingsState, oldVal: string, newVal: string, cb: () => void)

Source from the content-addressed store, hash-verified

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" }}>

Callers 1

SettingsManagerFunction · 0.85

Calls 1

notifyFunction · 0.85

Tested by

no test coverage detected