Fix notf close (#52)

* fix notf close

* send close event for queued items
This commit is contained in:
Lynn 2017-04-04 20:16:14 -07:00 committed by GitHub
parent 662fa1d864
commit 8d94893ea8
2 changed files with 16 additions and 18 deletions

View File

@ -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'
}

View File

@ -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() {