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>
This commit is contained in:
Michael Telatynski 2017-06-01 00:00:00 +01:00
parent 0e742cec27
commit 33ee42f821
2 changed files with 16 additions and 12 deletions

View File

@ -119,19 +119,19 @@ electron.ipcMain.on('install_update', installUpdate);
let focusHandlerAttached = false; let focusHandlerAttached = false;
electron.ipcMain.on('setBadgeCount', function(ev, count) { electron.ipcMain.on('setBadgeCount', function(ev, count) {
electron.app.setBadgeCount(count); electron.app.setBadgeCount(count);
if (process.platform === 'win32' && mainWindow && !mainWindow.isFocused()) { if (count === 0) {
if (count > 0) { mainWindow.flashFrame(false);
if (!focusHandlerAttached) { }
mainWindow.once('focus', () => { });
mainWindow.flashFrame(false);
focusHandlerAttached = false; electron.ipcMain.on('loudNotification', function() {
}); if (process.platform === 'win32' && mainWindow && !mainWindow.isFocused() && !focusHandlerAttached) {
focusHandlerAttached = true; mainWindow.flashFrame(true);
} mainWindow.once('focus', () => {
mainWindow.flashFrame(true);
} else {
mainWindow.flashFrame(false); mainWindow.flashFrame(false);
} focusHandlerAttached = false;
});
focusHandlerAttached = true;
} }
}); });

View File

@ -124,6 +124,10 @@ export default class ElectronPlatform extends VectorBasePlatform {
return notification; return notification;
} }
loudNotification(ev: Event, room: Object) {
ipcRenderer.send('loudNotification');
}
clearNotification(notif: Notification) { clearNotification(notif: Notification) {
notif.close(); notif.close();
} }