mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
Merge branch 'main' into SDA-3079
This commit is contained in:
commit
e42305e846
@ -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();
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user