From 486698845b67a354c03242962954239b5efe0085 Mon Sep 17 00:00:00 2001 From: Ronald Date: Tue, 21 Jun 2016 14:11:19 +0200 Subject: [PATCH 1/3] Don't fire close event after click Don't fire close event when the notification times out after the click event has been fired --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 59f0e12..0e807a8 100644 --- a/index.js +++ b/index.js @@ -297,13 +297,14 @@ function buildCloseNotification(notificationWindow, notificationObj, getTimeoutI closedNotifications[notificationObj.id] = true } - if (notificationWindow.electronNotifyOnCloseFunc) { + if (notificationWindow.electronNotifyOnCloseFunc && !notificationWindow.clickFunctionFired) { notificationWindow.electronNotifyOnCloseFunc({ event: event, id: notificationObj.id }) delete notificationWindow.electronNotifyOnCloseFunc } + delete notificationWindow.clickFunctionFired // reset content notificationWindow.webContents.send('electron-notify-reset') @@ -351,6 +352,7 @@ ipc.on('electron-notify-click', function (event, winId, notificationObj) { } let notificationWindow = BrowserWindow.fromId(winId) if (notificationWindow && notificationWindow.electronNotifyOnClickFunc) { + notificationWindow.clickFunctionFired = true let closeFunc = buildCloseNotification(notificationWindow, notificationObj) notificationWindow.electronNotifyOnClickFunc({ event: 'click', From 6384b67a66f32a04e0986fd6db16db5c37624a88 Mon Sep 17 00:00:00 2001 From: Ronald Date: Tue, 21 Jun 2016 14:21:13 +0200 Subject: [PATCH 2/3] Close notification after click fired Close the notification after a click callback was fired (without onClose firing). --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 0e807a8..b156130 100644 --- a/index.js +++ b/index.js @@ -361,6 +361,7 @@ ipc.on('electron-notify-click', function (event, winId, notificationObj) { }) delete notificationWindow.electronNotifyOnClickFunc } + closeFunc() }) /* From b022e81161c02e6bc9f83d10ae94d5a7f9690e7d Mon Sep 17 00:00:00 2001 From: Ronald Date: Wed, 22 Jun 2016 17:49:26 +0200 Subject: [PATCH 3/3] fixed type got that in the wrong line --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index b156130..6fa4592 100644 --- a/index.js +++ b/index.js @@ -360,8 +360,8 @@ ipc.on('electron-notify-click', function (event, winId, notificationObj) { closeNotification: buildCloseNotificationSafely(closeFunc) }) delete notificationWindow.electronNotifyOnClickFunc + closeFunc() } - closeFunc() }) /*