From 8d06b540916d4d6cdcc6e7f4f5c3f1f65d3e7ae8 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 6 Dec 2016 09:45:31 +0000 Subject: [PATCH 1/2] Only show window when ready Avoids it sitting there for a short period with no spinner while it parses the js. --- electron/src/electron-main.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/electron/src/electron-main.js b/electron/src/electron-main.js index 2ca0b9d3bd..57f4f66da5 100644 --- a/electron/src/electron-main.js +++ b/electron/src/electron-main.js @@ -159,10 +159,14 @@ electron.app.on('ready', () => { mainWindow = new electron.BrowserWindow({ icon: `${__dirname}/../img/riot.ico`, width: 1024, height: 768, + show: false, }); mainWindow.loadURL(`file://${__dirname}/../../webapp/index.html`); electron.Menu.setApplicationMenu(VectorMenu); + mainWindow.once('ready-to-show', () => { + mainWindow.show(); + }); mainWindow.on('closed', () => { mainWindow = null; }); From 5fa0f62ccc948473f68a3e4790ece29adb97944a Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 6 Dec 2016 13:28:59 +0000 Subject: [PATCH 2/2] Fix clicking on notifications * Dismiss the notification when it's clicked * Accept the room object: we need it to view_room * Desktop app: Un-minimise when notification clicked * Desktop App: Set App User Model ID so notifications work on Windows 8! --- electron/src/electron-main.js | 6 ++++++ src/vector/platform/ElectronPlatform.js | 3 ++- src/vector/platform/WebPlatform.js | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/electron/src/electron-main.js b/electron/src/electron-main.js index 57f4f66da5..788d46028c 100644 --- a/electron/src/electron-main.js +++ b/electron/src/electron-main.js @@ -202,3 +202,9 @@ electron.app.on('activate', () => { electron.app.on('before-quit', () => { appQuitting = true; }); + +// Set the App User Model ID to match what the squirrel +// installer uses for the shortcut icon. +// This makes notifications work on windows 8.1 (and is +// a noop on other platforms). +electron.app.setAppUserModelId('com.squirrel.riot-web.Riot'); diff --git a/src/vector/platform/ElectronPlatform.js b/src/vector/platform/ElectronPlatform.js index 3894896a01..d6f4013a7f 100644 --- a/src/vector/platform/ElectronPlatform.js +++ b/src/vector/platform/ElectronPlatform.js @@ -79,7 +79,7 @@ export default class ElectronPlatform extends VectorBasePlatform { return true; } - displayNotification(title: string, msg: string, avatarUrl: string): Notification { + displayNotification(title: string, msg: string, avatarUrl: string, room: Object): Notification { // Notifications in Electron use the HTML5 notification API const notification = new global.Notification( title, @@ -97,6 +97,7 @@ export default class ElectronPlatform extends VectorBasePlatform { room_id: room.roomId }); global.focus(); + electron.remote.getCurrentWindow().restore(); }; return notification; diff --git a/src/vector/platform/WebPlatform.js b/src/vector/platform/WebPlatform.js index 9998f7c78f..c4ed4d5550 100644 --- a/src/vector/platform/WebPlatform.js +++ b/src/vector/platform/WebPlatform.js @@ -103,7 +103,7 @@ export default class WebPlatform extends VectorBasePlatform { return defer.promise; } - displayNotification(title: string, msg: string, avatarUrl: string) { + displayNotification(title: string, msg: string, avatarUrl: string, room: Object) { const notification = new global.Notification( title, { @@ -120,6 +120,7 @@ export default class WebPlatform extends VectorBasePlatform { room_id: room.roomId }); global.focus(); + notification.close(); }; // Chrome only dismisses notifications after 20s, which