1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-29 22:53:44 +00:00

add a dispose method for cleanup of ipc handlers

This commit is contained in:
neuronull
2025-11-03 15:31:12 -07:00
parent 5812f552b2
commit 27d8f3f4f2
2 changed files with 12 additions and 1 deletions

View File

@@ -79,6 +79,17 @@ export class MainDesktopAutotypeService {
}
}
dispose() {
ipcMain.removeHandler(AUTOTYPE_IPC_CHANNELS.INIT);
ipcMain.removeHandler(AUTOTYPE_IPC_CHANNELS.INITIALIZED);
ipcMain.removeAllListeners(AUTOTYPE_IPC_CHANNELS.TOGGLE);
ipcMain.removeAllListeners(AUTOTYPE_IPC_CHANNELS.CONFIGURE);
ipcMain.removeAllListeners(AUTOTYPE_IPC_CHANNELS.EXECUTE);
// Also unregister the global shortcut
this.disableAutotype();
}
// Register the current keyboard shortcut if not already registered.
private enableAutotype() {
const formattedKeyboardShortcut = this.autotypeKeyboardShortcut.getElectronFormat();

View File

@@ -312,7 +312,7 @@ export class Main {
);
app.on("will-quit", () => {
this.mainDesktopAutotypeService.disableAutotype();
this.mainDesktopAutotypeService.dispose();
});
}