mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 05:04:57 +08:00
Merge pull request #3992 from vector-im/t3chguy/electron_call_sleep
Prevent Power Save when in call (Electron)
This commit is contained in:
commit
445a55c7ca
@ -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', () => {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user