From 9f461189c1e41f5aecc9ce103ec4cd297f5ffaee Mon Sep 17 00:00:00 2001 From: neuronull <9162534+neuronull@users.noreply.github.com> Date: Mon, 3 Nov 2025 15:20:26 -0700 Subject: [PATCH] ipc out of constructor --- .../services/desktop-autotype.service.ts | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/apps/desktop/src/autofill/services/desktop-autotype.service.ts b/apps/desktop/src/autofill/services/desktop-autotype.service.ts index 0da23beadda..b41e24537e2 100644 --- a/apps/desktop/src/autofill/services/desktop-autotype.service.ts +++ b/apps/desktop/src/autofill/services/desktop-autotype.service.ts @@ -74,6 +74,8 @@ export class DesktopAutotypeService implements OnDestroy { // The keyboard shortcut from the user settings menu autotypeKeyboardShortcut$: Observable = of(defaultWindowsAutotypeKeyboardShortcut); + private autotypeRequestListener?: () => void; + private destroy$ = new Subject(); constructor( @@ -106,16 +108,6 @@ export class DesktopAutotypeService implements OnDestroy { map((shortcut) => shortcut ?? defaultWindowsAutotypeKeyboardShortcut), takeUntil(this.destroy$), ); - - ipc.autofill.listenAutotypeRequest(async (windowTitle, callback) => { - const possibleCiphers = await this.matchCiphersToWindowTitle(windowTitle); - const firstCipher = possibleCiphers?.at(0); - - return callback(null, { - username: firstCipher?.login?.username, - password: firstCipher?.login?.password, - }); - }); } async init() { @@ -128,6 +120,18 @@ export class DesktopAutotypeService implements OnDestroy { await ipc.autofill.initAutotype(); } + this.autotypeRequestListener = ipc.autofill.listenAutotypeRequest( + async (windowTitle, callback) => { + const possibleCiphers = await this.matchCiphersToWindowTitle(windowTitle); + const firstCipher = possibleCiphers?.at(0); + + return callback(null, { + username: firstCipher?.login?.username, + password: firstCipher?.login?.password, + }); + }, + ); + // If `autotypeDefaultPolicy` is `true` for a user's organization, and the // user has never changed their local autotype setting (`autotypeEnabledState`), // we set their local setting to `true` (once the local user setting is changed