onAction support in Electron process, disable powersave when in call

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2017-05-22 18:32:39 +01:00
parent f57d8e4cb9
commit 4944bfdaa2

View File

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