diff --git a/apps/desktop/src/autofill/main/main-desktop-autotype.service.ts b/apps/desktop/src/autofill/main/main-desktop-autotype.service.ts index 8eba6955efd..25d8e4169a0 100644 --- a/apps/desktop/src/autofill/main/main-desktop-autotype.service.ts +++ b/apps/desktop/src/autofill/main/main-desktop-autotype.service.ts @@ -20,15 +20,15 @@ export class MainDesktopAutotypeService { } init() { - ipcMain.handle("autofill.initAutotype", () => { + ipcMain.handle(AUTOTYPE_IPC_CHANNELS.INIT, () => { this.init(); }); - ipcMain.handle("autofill.autotypeIsInitialized", () => { + ipcMain.handle(AUTOTYPE_IPC_CHANNELS.INITIALIZED, () => { return this.isInitialized; }); - ipcMain.on("autofill.toggleAutotype", (_event, enable: boolean) => { + ipcMain.on(AUTOTYPE_IPC_CHANNELS.TOGGLE, (_event, enable: boolean) => { if (enable) { this.enableAutotype(); } else { @@ -36,7 +36,7 @@ export class MainDesktopAutotypeService { } }); - ipcMain.on("autofill.configureAutotype", (_event, config: AutotypeConfig) => { + ipcMain.on(AUTOTYPE_IPC_CHANNELS.CONFIGURE, (_event, config: AutotypeConfig) => { const newKeyboardShortcut = new AutotypeKeyboardShortcut(); const newKeyboardShortcutIsValid = newKeyboardShortcut.set(config.keyboardShortcut); @@ -48,7 +48,7 @@ export class MainDesktopAutotypeService { this.setKeyboardShortcut(newKeyboardShortcut); }); - ipcMain.on("autofill.completeAutotypeRequest", (_event, data) => { + ipcMain.on(AUTOTYPE_IPC_CHANNELS.EXECUTE, (_event, data) => { const { response } = data; if ( @@ -91,7 +91,7 @@ export class MainDesktopAutotypeService { () => { const windowTitle = autotype.getForegroundWindowTitle(); - this.windowMain.win.webContents.send("autofill.listenAutotypeRequest", { + this.windowMain.win.webContents.send(AUTOTYPE_IPC_CHANNELS.LISTEN, { windowTitle, }); }, diff --git a/apps/desktop/src/autofill/models/ipc-channels.ts b/apps/desktop/src/autofill/models/ipc-channels.ts new file mode 100644 index 00000000000..5fea2daf0cf --- /dev/null +++ b/apps/desktop/src/autofill/models/ipc-channels.ts @@ -0,0 +1,9 @@ +export const AUTOTYPE_IPC_CHANNELS = { + INIT: "autofill.initAutotype", + INITIALIZED: "autofill.autotypeIsInitialized", + TOGGLE: "autofill.toggleAutotype", + CONFIGURE: "autofill.configureAutotype", + LISTEN: "autofill.listenAutotypeRequest", + EXECUTION_ERROR: "autofill.autotypeExecutionError", + EXECUTE: "autofill.executeAutotype", +} as const; diff --git a/apps/desktop/src/autofill/preload.ts b/apps/desktop/src/autofill/preload.ts index 7db01b122ce..01fa1c692f9 100644 --- a/apps/desktop/src/autofill/preload.ts +++ b/apps/desktop/src/autofill/preload.ts @@ -6,6 +6,7 @@ import { Command } from "../platform/main/autofill/command"; import { RunCommandParams, RunCommandResult } from "../platform/main/autofill/native-autofill.main"; import { AutotypeConfig } from "./models/autotype-configure"; +import { AUTOTYPE_IPC_CHANNELS } from "./models/ipc-channels"; export default { runCommand: (params: RunCommandParams): Promise> => @@ -130,16 +131,16 @@ export default { ); }, initAutotype: () => { - return ipcRenderer.invoke("autofill.initAutotype"); + return ipcRenderer.invoke(AUTOTYPE_IPC_CHANNELS.INIT); }, autotypeIsInitialized: () => { - return ipcRenderer.invoke("autofill.autotypeIsInitialized"); + return ipcRenderer.invoke(AUTOTYPE_IPC_CHANNELS.INITIALIZED); }, configureAutotype: (config: AutotypeConfig) => { - ipcRenderer.send("autofill.configureAutotype", config); + ipcRenderer.send(AUTOTYPE_IPC_CHANNELS.CONFIGURE, config); }, toggleAutotype: (enable: boolean) => { - ipcRenderer.send("autofill.toggleAutotype", enable); + ipcRenderer.send(AUTOTYPE_IPC_CHANNELS.TOGGLE, enable); }, listenAutotypeRequest: ( fn: ( @@ -151,7 +152,7 @@ export default { ) => void, ) => { ipcRenderer.on( - "autofill.listenAutotypeRequest", + AUTOTYPE_IPC_CHANNELS.LISTEN, ( event, data: { @@ -162,14 +163,14 @@ export default { fn(windowTitle, (error, response) => { if (error) { - ipcRenderer.send("autofill.completeError", { + ipcRenderer.send(AUTOTYPE_IPC_CHANNELS.EXECUTION_ERROR, { windowTitle, error: error.message, }); return; } - ipcRenderer.send("autofill.completeAutotypeRequest", { + ipcRenderer.send(AUTOTYPE_IPC_CHANNELS.EXECUTE, { windowTitle, response, });