diff --git a/electron_app/src/electron-main.js b/electron_app/src/electron-main.js index 26f8f972..6f712050 100644 --- a/electron_app/src/electron-main.js +++ b/electron_app/src/electron-main.js @@ -138,6 +138,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) => { @@ -151,7 +169,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', () => { diff --git a/src/vector/platform/ElectronPlatform.js b/src/vector/platform/ElectronPlatform.js index 5710e66e..bf930a67 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); @@ -71,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