mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
Electron-222
Added a safety check to prevent from using an already destroyed notification window Added method to close all notification when notification config is changed
This commit is contained in:
parent
5ed8e8f026
commit
c8101a9b1e
@ -165,6 +165,7 @@ function updateConfig(customConfig) {
|
|||||||
if (customConfig.display) {
|
if (customConfig.display) {
|
||||||
displayId = customConfig.display;
|
displayId = customConfig.display;
|
||||||
}
|
}
|
||||||
|
closeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -477,6 +478,13 @@ function setNotificationContents(notfWindow, notfObj) {
|
|||||||
*/
|
*/
|
||||||
function buildCloseNotification(notificationWindow, notificationObj, getTimeoutId) {
|
function buildCloseNotification(notificationWindow, notificationObj, getTimeoutId) {
|
||||||
return function(event) {
|
return function(event) {
|
||||||
|
|
||||||
|
// safety check to prevent from using an
|
||||||
|
// already destroyed notification window
|
||||||
|
if (notificationWindow.isDestroyed()) {
|
||||||
|
return new Promise(function(exitEarly) { exitEarly() })
|
||||||
|
}
|
||||||
|
|
||||||
if (closedNotifications[notificationObj.id]) {
|
if (closedNotifications[notificationObj.id]) {
|
||||||
delete closedNotifications[notificationObj.id];
|
delete closedNotifications[notificationObj.id];
|
||||||
return new Promise(function(exitEarly) { exitEarly() });
|
return new Promise(function(exitEarly) { exitEarly() });
|
||||||
@ -711,6 +719,34 @@ function cleanUpInactiveWindow() {
|
|||||||
inactiveWindows = [];
|
inactiveWindows = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes all the notifications and windows
|
||||||
|
*/
|
||||||
|
function closeAll() {
|
||||||
|
// Clear out animation Queue and close windows
|
||||||
|
animationQueue.clear();
|
||||||
|
|
||||||
|
activeNotifications.forEach(function(window) {
|
||||||
|
if (window.displayTimer) {
|
||||||
|
clearTimeout(window.displayTimer);
|
||||||
|
}
|
||||||
|
if (window.electronNotifyOnCloseFunc) {
|
||||||
|
// ToDo: fix this: shouldn't delete method on arg
|
||||||
|
/* eslint-disable */
|
||||||
|
delete window.electronNotifyOnCloseFunc;
|
||||||
|
/* eslint-enable */
|
||||||
|
}
|
||||||
|
window.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
cleanUpInactiveWindow();
|
||||||
|
|
||||||
|
// Reset certain vars
|
||||||
|
nextInsertPos = {};
|
||||||
|
activeNotifications = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports.notify = notify;
|
module.exports.notify = notify;
|
||||||
module.exports.updateConfig = updateConfig;
|
module.exports.updateConfig = updateConfig;
|
||||||
module.exports.reset = setupConfig;
|
module.exports.reset = setupConfig;
|
||||||
|
Loading…
Reference in New Issue
Block a user