From 8d94893ea854d3e5f494120908774305d2a65cf4 Mon Sep 17 00:00:00 2001 From: Lynn Date: Tue, 4 Apr 2017 20:16:14 -0700 Subject: [PATCH] Fix notf close (#52) * fix notf close * send close event for queued items --- js/enums/api.js | 13 ------------- js/notify/electron-notify.js | 21 ++++++++++++++++----- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/js/enums/api.js b/js/enums/api.js index 58ec7a93..19d2d404 100644 --- a/js/enums/api.js +++ b/js/enums/api.js @@ -10,20 +10,7 @@ const cmds = keyMirror({ badgeDataUrl: null }); -const proxyCmds = keyMirror({ - createObject: null, - addEvent: null, - removeEvent: null, - eventCallback: null, - invokeMethod: null, - invokeResult: null, - get: null, - getResult: null, - set: null -}); - module.exports = { cmds: cmds, - proxyCmds: proxyCmds, apiName: 'symphony-api' } diff --git a/js/notify/electron-notify.js b/js/notify/electron-notify.js index 64a44480..f719109a 100644 --- a/js/notify/electron-notify.js +++ b/js/notify/electron-notify.js @@ -274,18 +274,29 @@ function showNotification(notificationObj) { // if has same grouping id. let tag = notificationObj.tag; if (tag) { - // first check waiting items + // first check queued notifications for(let i = 0; i < notificationQueue.length; i++) { if (tag === notificationQueue[ i ].tag) { + let existingNotfObj = notificationQueue[ i ]; + // be sure to call close event for existing, so it gets + // cleaned up. + if (typeof existingNotfObj.onCloseFunc === 'function') { + existingNotfObj.onCloseFunc({ + event: 'close', + id: notificationObj.id + }); + } + // update with new notf notificationQueue[ i ] = notificationObj; resolve(); return; } } - // next check items being shown + // next check notfs being shown for(let i = 0; i < activeNotifications.length; i++) { - if (tag === activeNotifications[ i ].tag) { + let existingNotfyObj = activeNotifications[ i ].notfyObj; + if (existingNotfyObj && tag === existingNotfyObj.tag) { let notificationWindow = activeNotifications[ i ]; // be sure to call close event for existing, so it gets @@ -293,7 +304,7 @@ function showNotification(notificationObj) { if (notificationWindow.electronNotifyOnCloseFunc) { notificationWindow.electronNotifyOnCloseFunc({ event: 'close', - id: notificationObj.id + id: existingNotfyObj.id }); delete notificationWindow.electronNotifyOnCloseFunc; } @@ -337,7 +348,7 @@ function setNotificationContents(notfWindow, notfObj) { var updatedNotificationWindow = notfWindow; - updatedNotificationWindow.tag = notfObj.tag; + updatedNotificationWindow.notfyObj = notfObj; let timeoutId; let closeFunc = buildCloseNotification(notfWindow, notfObj, function() {