From 755c66b9f19b51bd65d7289873553c387bc5ff5d Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 22 May 2017 18:30:45 +0100 Subject: [PATCH 1/3] pass dispatcher through to electron, on a whitelist basis Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/vector/platform/ElectronPlatform.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/vector/platform/ElectronPlatform.js b/src/vector/platform/ElectronPlatform.js index 5710e66e..ecbc5bd0 100644 --- a/src/vector/platform/ElectronPlatform.js +++ b/src/vector/platform/ElectronPlatform.js @@ -54,7 +54,19 @@ function platformFriendlyName(): string { } } +function _onAction(payload: Object) { + // Whitelist payload actions, no point sending most across + if (['call_state'].includes(payload.action)) { + ipcRenderer.send('app_onAction', payload); + } +} + export default class ElectronPlatform extends VectorBasePlatform { + constructor() { + super(); + dis.register(_onAction); + } + setNotificationCount(count: number) { if (this.notificationCount === count) return; super.setNotificationCount(count); From f57d8e4cb9bd3d87a28462e6c697dd087f4fd8a1 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 22 May 2017 18:31:30 +0100 Subject: [PATCH 2/3] make ESLint a touch happier Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/vector/platform/ElectronPlatform.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vector/platform/ElectronPlatform.js b/src/vector/platform/ElectronPlatform.js index ecbc5bd0..bf930a67 100644 --- a/src/vector/platform/ElectronPlatform.js +++ b/src/vector/platform/ElectronPlatform.js @@ -83,7 +83,6 @@ export default class ElectronPlatform extends VectorBasePlatform { } displayNotification(title: string, msg: string, avatarUrl: string, room: Object): Notification { - // GNOME notification spec parses HTML tags for styling... // Electron Docs state all supported linux notification systems follow this markup spec // https://github.com/electron/electron/blob/master/docs/tutorial/desktop-environment-integration.md#linux From 4944bfdaa25abbeb4ebd8ce60fbc7376851b5bbd Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 22 May 2017 18:32:39 +0100 Subject: [PATCH 3/3] onAction support in Electron process, disable powersave when in call Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- electron_app/src/electron-main.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/electron_app/src/electron-main.js b/electron_app/src/electron-main.js index ab844bd3..53f9ac0f 100644 --- a/electron_app/src/electron-main.js +++ b/electron_app/src/electron-main.js @@ -186,6 +186,24 @@ electron.ipcMain.on('setBadgeCount', function(ev, count) { } }); +let powerSaveBlockerId; +electron.ipcMain.on('app_onAction', function(ev, payload) { + switch (payload.action) { + case 'call_state': + if (powerSaveBlockerId && powerSaveBlockerId.isStarted(powerSaveBlockerId)) { + if (payload.state === 'ended') { + electron.powerSaveBlocker.stop(powerSaveBlockerId); + } + } else { + if (payload.state === 'connected') { + powerSaveBlockerId = electron.powerSaveBlocker.start('prevent-display-sleep'); + } + } + break; + } +}); + + electron.app.commandLine.appendSwitch('--enable-usermedia-screen-capturing'); const shouldQuit = electron.app.makeSingleInstance((commandLine, workingDirectory) => { @@ -199,7 +217,7 @@ const shouldQuit = electron.app.makeSingleInstance((commandLine, workingDirector if (shouldQuit) { console.log("Other instance detected: exiting"); - electron.app.quit() + electron.app.quit(); } electron.app.on('ready', () => {