onAction support in Electron process, disable powersave when in call
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
f57d8e4cb9
commit
4944bfdaa2
1 changed files with 19 additions and 1 deletions
|
@ -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');
|
electron.app.commandLine.appendSwitch('--enable-usermedia-screen-capturing');
|
||||||
|
|
||||||
const shouldQuit = electron.app.makeSingleInstance((commandLine, workingDirectory) => {
|
const shouldQuit = electron.app.makeSingleInstance((commandLine, workingDirectory) => {
|
||||||
|
@ -199,7 +217,7 @@ const shouldQuit = electron.app.makeSingleInstance((commandLine, workingDirector
|
||||||
|
|
||||||
if (shouldQuit) {
|
if (shouldQuit) {
|
||||||
console.log("Other instance detected: exiting");
|
console.log("Other instance detected: exiting");
|
||||||
electron.app.quit()
|
electron.app.quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
electron.app.on('ready', () => {
|
electron.app.on('ready', () => {
|
||||||
|
|
Loading…
Reference in a new issue