mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-29 02:11:28 -06:00
SDA-3673 - Publish main events only for events from main window (#1397)
This commit is contained in:
parent
4494e19956
commit
fec162d72b
@ -99,11 +99,16 @@ const windowMaximized = async (): Promise<void> => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const throttledWindowChanges = throttle(async (eventName) => {
|
const throttledWindowChanges = throttle(async (eventName, window) => {
|
||||||
await saveWindowSettings();
|
await saveWindowSettings();
|
||||||
await windowMaximized();
|
await windowMaximized();
|
||||||
notification.moveNotificationToTop();
|
notification.moveNotificationToTop();
|
||||||
mainEvents.publish(eventName);
|
if (
|
||||||
|
window &&
|
||||||
|
(window as ICustomBrowserWindow).winName === apiName.mainWindowName
|
||||||
|
) {
|
||||||
|
mainEvents.publish(eventName);
|
||||||
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
const throttledWindowRestore = throttle(async () => {
|
const throttledWindowRestore = throttle(async () => {
|
||||||
@ -304,18 +309,18 @@ export const monitorWindowActions = (window: BrowserWindow): void => {
|
|||||||
eventNames.forEach((event: string) => {
|
eventNames.forEach((event: string) => {
|
||||||
if (window) {
|
if (window) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
window.on(event, () => throttledWindowChanges(event));
|
window.on(event, () => throttledWindowChanges(event, window));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
window.on('enter-full-screen', () =>
|
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', () =>
|
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) {
|
if ((window as ICustomBrowserWindow).winName === apiName.mainWindowName) {
|
||||||
window.on('restore', throttledWindowRestore);
|
window.on('restore', throttledWindowRestore);
|
||||||
|
Loading…
Reference in New Issue
Block a user