From 33ee42f821300021102877030db96419c238eaab Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 1 Jun 2017 00:00:00 +0100 Subject: [PATCH] use loudNotification for flashFrame, resetting on count=0 or focus win32 check is optional just there so we're not attaching pointless handlers Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- electron_app/src/electron-main.js | 24 ++++++++++++------------ src/vector/platform/ElectronPlatform.js | 4 ++++ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/electron_app/src/electron-main.js b/electron_app/src/electron-main.js index f21fe1c0..a5708164 100644 --- a/electron_app/src/electron-main.js +++ b/electron_app/src/electron-main.js @@ -119,19 +119,19 @@ electron.ipcMain.on('install_update', installUpdate); let focusHandlerAttached = false; electron.ipcMain.on('setBadgeCount', function(ev, count) { electron.app.setBadgeCount(count); - if (process.platform === 'win32' && mainWindow && !mainWindow.isFocused()) { - if (count > 0) { - if (!focusHandlerAttached) { - mainWindow.once('focus', () => { - mainWindow.flashFrame(false); - focusHandlerAttached = false; - }); - focusHandlerAttached = true; - } - mainWindow.flashFrame(true); - } else { + if (count === 0) { + mainWindow.flashFrame(false); + } +}); + +electron.ipcMain.on('loudNotification', function() { + if (process.platform === 'win32' && mainWindow && !mainWindow.isFocused() && !focusHandlerAttached) { + mainWindow.flashFrame(true); + mainWindow.once('focus', () => { mainWindow.flashFrame(false); - } + focusHandlerAttached = false; + }); + focusHandlerAttached = true; } }); diff --git a/src/vector/platform/ElectronPlatform.js b/src/vector/platform/ElectronPlatform.js index 06ea2136..7cfe36ef 100644 --- a/src/vector/platform/ElectronPlatform.js +++ b/src/vector/platform/ElectronPlatform.js @@ -124,6 +124,10 @@ export default class ElectronPlatform extends VectorBasePlatform { return notification; } + loudNotification(ev: Event, room: Object) { + ipcRenderer.send('loudNotification'); + } + clearNotification(notif: Notification) { notif.close(); }