From 71c12d91e63056b39b3036bb48b3a8f998905dcc Mon Sep 17 00:00:00 2001 From: trazyn Date: Mon, 18 Sep 2017 15:27:26 +0800 Subject: [PATCH] click notification show the main window --- main.js | 7 +++++++ src/js/stores/chat.js | 8 +++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index 0f69451..2649604 100644 --- a/main.js +++ b/main.js @@ -488,6 +488,13 @@ const createMainWindow = () => { } }); + ipcMain.on('show-window', event => { + if (!mainWindow.isVisible()) { + mainWindow.show(); + mainWindow.focus(); + } + }); + ipcMain.on('menu-update', (event, args) => { var { contacts, conversations } = args; diff --git a/src/js/stores/chat.js b/src/js/stores/chat.js index efc09a8..ba76c91 100644 --- a/src/js/stores/chat.js +++ b/src/js/stores/chat.js @@ -372,13 +372,15 @@ class Chat { if (!helper.isMuted(user) && !sync && settings.showNotification) { - /* eslint-disable */ - new Notification(title, { + let notification = new window.Notification(title, { icon: user.HeadImgUrl, body: helper.getMessageContent(message), vibrate: [200, 100, 200], }); - /* eslint-enable */ + + notification.onclick = () => { + ipcRenderer.send('show-window'); + }; } list.data.push(message); }