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');
|
electron.app.commandLine.appendSwitch('--enable-usermedia-screen-capturing');
|
||||||
|
|
||||||
const shouldQuit = electron.app.makeSingleInstance((commandLine, workingDirectory) => {
|
const shouldQuit = electron.app.makeSingleInstance((commandLine, workingDirectory) => {
|
||||||
|
@ -151,7 +169,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', () => {
|
||||||
|
|
|
@ -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 {
|
export default class ElectronPlatform extends VectorBasePlatform {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
dis.register(_onAction);
|
||||||
|
}
|
||||||
|
|
||||||
setNotificationCount(count: number) {
|
setNotificationCount(count: number) {
|
||||||
if (this.notificationCount === count) return;
|
if (this.notificationCount === count) return;
|
||||||
super.setNotificationCount(count);
|
super.setNotificationCount(count);
|
||||||
|
@ -71,7 +83,6 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
||||||
}
|
}
|
||||||
|
|
||||||
displayNotification(title: string, msg: string, avatarUrl: string, room: Object): Notification {
|
displayNotification(title: string, msg: string, avatarUrl: string, room: Object): Notification {
|
||||||
|
|
||||||
// GNOME notification spec parses HTML tags for styling...
|
// GNOME notification spec parses HTML tags for styling...
|
||||||
// Electron Docs state all supported linux notification systems follow this markup spec
|
// 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
|
// https://github.com/electron/electron/blob/master/docs/tutorial/desktop-environment-integration.md#linux
|
||||||
|
|
Loading…
Reference in New Issue