SDA-3673 - Publish main events only for events from main window (#1397)

This commit is contained in:
Kiran Niranjan 2022-04-28 12:34:11 +05:30 committed by GitHub
parent 4494e19956
commit fec162d72b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -99,11 +99,16 @@ const windowMaximized = async (): Promise<void> => {
}
};
const throttledWindowChanges = throttle(async (eventName) => {
const throttledWindowChanges = throttle(async (eventName, window) => {
await saveWindowSettings();
await windowMaximized();
notification.moveNotificationToTop();
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);