From fec162d72b05da44841f5917da0eb01758b8c5be Mon Sep 17 00:00:00 2001 From: Kiran Niranjan Date: Thu, 28 Apr 2022 12:34:11 +0530 Subject: [PATCH] SDA-3673 - Publish main events only for events from main window (#1397) --- src/app/window-actions.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/app/window-actions.ts b/src/app/window-actions.ts index d780f33d..a39aa612 100644 --- a/src/app/window-actions.ts +++ b/src/app/window-actions.ts @@ -99,11 +99,16 @@ const windowMaximized = async (): Promise => { } }; -const throttledWindowChanges = throttle(async (eventName) => { +const throttledWindowChanges = throttle(async (eventName, window) => { await saveWindowSettings(); await windowMaximized(); notification.moveNotificationToTop(); - mainEvents.publish(eventName); + if ( + window && + (window as ICustomBrowserWindow).winName === apiName.mainWindowName + ) { + mainEvents.publish(eventName); + } }, 1000); const throttledWindowRestore = throttle(async () => { @@ -304,18 +309,18 @@ export const monitorWindowActions = (window: BrowserWindow): void => { eventNames.forEach((event: string) => { if (window) { // @ts-ignore - window.on(event, () => throttledWindowChanges(event)); + window.on(event, () => throttledWindowChanges(event, window)); } }); window.on('enter-full-screen', () => - throttledWindowChanges('enter-full-screen'), + throttledWindowChanges('enter-full-screen', window), ); - window.on('maximize', () => throttledWindowChanges('maximize')); + window.on('maximize', () => throttledWindowChanges('maximize', window)); window.on('leave-full-screen', () => - throttledWindowChanges('leave-full-screen'), + throttledWindowChanges('leave-full-screen', window), ); - window.on('unmaximize', () => throttledWindowChanges('unmaximize')); + window.on('unmaximize', () => throttledWindowChanges('unmaximize', window)); if ((window as ICustomBrowserWindow).winName === apiName.mainWindowName) { window.on('restore', throttledWindowRestore);