(feat): add hotkeys
This commit is contained in:
parent
915568f739
commit
85633a1c81
27 changed files with 1014 additions and 33 deletions
|
|
@ -2,6 +2,7 @@ import { contextBridge, ipcRenderer } from "electron";
|
|||
import {
|
||||
ipcChannels,
|
||||
type DesktopCallStatus,
|
||||
type DesktopGlobalHotkeyBinding,
|
||||
type DesktopScreenShareSource,
|
||||
secureStorageLimits,
|
||||
} from "../shared/ipc.js";
|
||||
|
|
@ -55,6 +56,23 @@ const desktopApi = {
|
|||
return ipcRenderer.invoke(ipcChannels.setCallStatus, status);
|
||||
},
|
||||
},
|
||||
hotkeys: {
|
||||
setBindings: (bindings: DesktopGlobalHotkeyBinding[]) =>
|
||||
ipcRenderer.invoke(ipcChannels.setGlobalHotkeyBindings, bindings),
|
||||
setSuspended: (suspended: boolean) =>
|
||||
typeof suspended === "boolean"
|
||||
? ipcRenderer.invoke(ipcChannels.setGlobalHotkeysSuspended, suspended)
|
||||
: Promise.reject(new Error("Invalid hotkey suspension state.")),
|
||||
onTriggered: (callback: (id: string) => void) => {
|
||||
const listener = (_event: Electron.IpcRendererEvent, id: unknown) => {
|
||||
if (typeof id === "string") callback(id);
|
||||
};
|
||||
ipcRenderer.on(ipcChannels.globalHotkeyTriggered, listener);
|
||||
return () => {
|
||||
ipcRenderer.removeListener(ipcChannels.globalHotkeyTriggered, listener);
|
||||
};
|
||||
},
|
||||
},
|
||||
secureStorage: {
|
||||
getStatus: () => ipcRenderer.invoke(ipcChannels.getSecureStorageStatus),
|
||||
load: (key: string) =>
|
||||
|
|
|
|||
Loading…
Reference in a new issue