From c3923e3ecdc217e15546fc1890b003fe1523de2d Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Sun, 27 Jan 2019 17:05:08 +0100 Subject: [PATCH] Add a workaround for a notifications bug in Electron --- index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/index.js b/index.js index c8f728677..a169c899f 100644 --- a/index.js +++ b/index.js @@ -413,6 +413,8 @@ app.on('before-quit', () => { config.set('lastWindowState', mainWindow.getNormalBounds()); }); +const notifications = new Map(); + ipcMain.on('notification', (event, {id, title, body, icon, silent}) => { const notification = new Notification({ title, @@ -422,18 +424,26 @@ ipcMain.on('notification', (event, {id, title, body, icon, silent}) => { silent }); + notifications.set(id, notification); + notification.on('click', () => { mainWindow.show(); sendAction('notification-callback', {callbackName: 'onclick', id}); + + notifications.delete(id); }); notification.on('reply', (event, reply) => { // We use onclick event used by messenger to go to the right convo sendBackgroundAction('notification-reply-callback', {callbackName: 'onclick', id, reply}); + + notifications.delete(id); }); notification.on('close', () => { sendAction('notification-callback', {callbackName: 'onclose', id}); + + notifications.delete(id); }); notification.show();