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] 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', () => {