From 29423f474a07f074987f8d7631718e1f48c8244e Mon Sep 17 00:00:00 2001 From: James Wheare Date: Thu, 16 May 2019 18:47:33 +0100 Subject: [PATCH] Restore notificationclick handler to activate the app. Fixes #16 --- app/render/notification.js | 18 ++++++++++++++++++ app/render/preload.js | 1 + 2 files changed, 19 insertions(+) create mode 100644 app/render/notification.js diff --git a/app/render/notification.js b/app/render/notification.js new file mode 100644 index 0000000..58cee82 --- /dev/null +++ b/app/render/notification.js @@ -0,0 +1,18 @@ +var remote = require('electron').remote; + +function listenNotification() { + remote.getCurrentWindow().webContents.executeJavaScript( + 'new Promise((resolve, reject) => { if (SESSION) { console.log("SESSION avail"); SESSION.on("notificationClick", function () { resolve(); }); } });' + ).then(() => { + remote.app.emit('activate'); + listenNotification(); + }); +} + +function setupNotificationHandler() { + document.addEventListener("DOMContentLoaded", function (event) { + listenNotification(); + }); +} + +module.exports = setupNotificationHandler; \ No newline at end of file diff --git a/app/render/preload.js b/app/render/preload.js index 4bac9b5..b065332 100644 --- a/app/render/preload.js +++ b/app/render/preload.js @@ -24,6 +24,7 @@ require('./focus')(); require('./zoom')(); require('./spellcheck')(); + require('./notification')(); require('./irc-url')(); require('./user')();