You've already forked element-web
mirror of
https://github.com/element-hq/element-web.git
synced 2025-11-29 21:23:11 +03:00
Merge pull request #3992 from vector-im/t3chguy/electron_call_sleep
Prevent Power Save when in call (Electron)
This commit is contained in:
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user