Merge branch 'main' into SDA-3079

This commit is contained in:
mattias-symphony 2021-04-13 14:31:17 +02:00 committed by GitHub
commit e42305e846
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 2 deletions

View File

@ -1,7 +1,8 @@
import { app } from 'electron';
import { app, powerSaveBlocker } from 'electron';
import { logger } from '../common/logger';
class AppStateHandler {
private id?: number;
/**
* Restarts the app with the command line arguments
* passed from the previous session
@ -11,6 +12,33 @@ class AppStateHandler {
app.relaunch();
app.exit();
}
/**
* Prevent the display to go to sleep
*/
public preventDisplaySleep(preventSleep: boolean) {
logger.info(
'App-state: preventDisplaySleep, preventSleep: ' + preventSleep,
);
if (preventSleep) {
if (this.id) {
logger.info(
'App-state: Stop previous power save blocker, id: ' + this.id,
);
powerSaveBlocker.stop(this.id);
this.id = undefined;
}
this.id = powerSaveBlocker.start('prevent-display-sleep');
logger.info('App-state: Prevent display to sleep, id: ' + this.id);
} else {
if (this.id) {
logger.info('App-state: Allow display to sleep, id: ' + this.id);
powerSaveBlocker.stop(this.id);
this.id = undefined;
}
}
}
}
const appStateHandler = new AppStateHandler();

View File

@ -206,6 +206,7 @@ ipcMain.on(
case apiCmds.setIsInMeeting:
if (typeof arg.isInMeeting === 'boolean') {
memoryMonitor.setMeetingStatus(arg.isInMeeting);
appStateHandler.preventDisplaySleep(arg.isInMeeting);
}
break;
case apiCmds.memoryInfo: