mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
Electron-235 (Fix javascript error in notification) (#326)
- Fix javascript error "object has been destroyed" - Fix notification javascript error and position issue - Remove unused export
This commit is contained in:
parent
ecb0f88660
commit
6914f30151
@ -164,6 +164,18 @@ function setStyleOnDomElement(styleObj, domElement) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.addEventListener('keydown', handleKeyPress, true);
|
||||||
|
window.addEventListener('keyup', handleKeyPress, true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method the prevent key stroke on notification window
|
||||||
|
*
|
||||||
|
* @param e keydown event
|
||||||
|
*/
|
||||||
|
function handleKeyPress(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the config
|
* Loads the config
|
||||||
* @param event
|
* @param event
|
||||||
|
@ -361,6 +361,7 @@ function showNotification(notificationObj) {
|
|||||||
|
|
||||||
// next check notfs being shown
|
// next check notfs being shown
|
||||||
for(let i = 0; i < activeNotifications.length; i++) {
|
for(let i = 0; i < activeNotifications.length; i++) {
|
||||||
|
if (activeNotifications[ i ] && !activeNotifications[ i ].isDestroyed()) {
|
||||||
let existingNotfyObj = activeNotifications[ i ].notfyObj;
|
let existingNotfyObj = activeNotifications[ i ].notfyObj;
|
||||||
if (existingNotfyObj && tag === existingNotfyObj.tag) {
|
if (existingNotfyObj && tag === existingNotfyObj.tag) {
|
||||||
let notificationWindow = activeNotifications[ i ];
|
let notificationWindow = activeNotifications[ i ];
|
||||||
@ -380,6 +381,7 @@ function showNotification(notificationObj) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Can we show it?
|
// Can we show it?
|
||||||
if (activeNotifications.length < config.maxVisibleNotifications) {
|
if (activeNotifications.length < config.maxVisibleNotifications) {
|
||||||
@ -698,7 +700,9 @@ function getWindow() {
|
|||||||
// Done
|
// Done
|
||||||
notificationWindow.webContents.send('electron-notify-load-config', config);
|
notificationWindow.webContents.send('electron-notify-load-config', config);
|
||||||
resolve(notificationWindow)
|
resolve(notificationWindow)
|
||||||
})
|
});
|
||||||
|
|
||||||
|
notificationWindow.once('closed', cleanUpActiveNotification);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -708,12 +712,29 @@ function getWindow() {
|
|||||||
*/
|
*/
|
||||||
setInterval(cleanUpInactiveWindow, 60000);
|
setInterval(cleanUpInactiveWindow, 60000);
|
||||||
|
|
||||||
|
function cleanUpActiveNotification(event) {
|
||||||
|
|
||||||
|
if (!event || !event.sender) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
let pos = activeNotifications.indexOf(event.sender);
|
||||||
|
if (pos !== -1) {
|
||||||
|
activeNotifications.splice(pos, 1);
|
||||||
|
return moveOneDown(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleans up inactive windows
|
* Cleans up inactive windows
|
||||||
*/
|
*/
|
||||||
function cleanUpInactiveWindow() {
|
function cleanUpInactiveWindow() {
|
||||||
inactiveWindows.forEach(function(window) {
|
inactiveWindows.forEach(function(window) {
|
||||||
|
if (!window.isDestroyed()) {
|
||||||
window.close();
|
window.close();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
inactiveWindows = [];
|
inactiveWindows = [];
|
||||||
}
|
}
|
||||||
@ -725,11 +746,15 @@ function closeAll() {
|
|||||||
// Clear out animation Queue and close windows
|
// Clear out animation Queue and close windows
|
||||||
animationQueue.clear();
|
animationQueue.clear();
|
||||||
|
|
||||||
activeNotifications.forEach(function(window) {
|
let notificationWindows = Array.from(activeNotifications);
|
||||||
|
|
||||||
|
notificationWindows.forEach((window) => {
|
||||||
if (window.displayTimer) {
|
if (window.displayTimer) {
|
||||||
clearTimeout(window.displayTimer);
|
clearTimeout(window.displayTimer);
|
||||||
}
|
}
|
||||||
|
if (!window.isDestroyed()) {
|
||||||
window.close();
|
window.close();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cleanUpInactiveWindow();
|
cleanUpInactiveWindow();
|
||||||
|
@ -155,6 +155,7 @@ function updateConfig() {
|
|||||||
*/
|
*/
|
||||||
function updateNotification(mPosition, mDisplay) {
|
function updateNotification(mPosition, mDisplay) {
|
||||||
notify.updateConfig({position: mPosition, display: mDisplay});
|
notify.updateConfig({position: mPosition, display: mDisplay});
|
||||||
|
eventEmitter.emit('notificationSettings', {position: mPosition, display: mDisplay});
|
||||||
notify.reset();
|
notify.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user