Prevent display sleep while on a call

This commit is contained in:
Evan Hahn 2021-12-10 16:53:10 -06:00 committed by GitHub
parent 34fd945f83
commit 0e3d12c457
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 152 additions and 0 deletions

View file

@ -19,6 +19,7 @@ import {
dialog,
ipcMain as ipc,
Menu,
powerSaveBlocker,
protocol as electronProtocol,
screen,
shell,
@ -54,6 +55,7 @@ import * as attachments from './attachments';
import * as attachmentChannel from './attachment_channel';
import * as bounce from '../ts/services/bounce';
import * as updater from '../ts/updater/index';
import { PreventDisplaySleepService } from './PreventDisplaySleepService';
import { SystemTrayService } from './SystemTrayService';
import { SystemTraySettingCache } from './SystemTraySettingCache';
import {
@ -120,6 +122,10 @@ const enableCI = config.get<boolean>('enableCI');
const sql = new MainSQL();
const heicConverter = getHeicConverter();
const preventDisplaySleepService = new PreventDisplaySleepService(
powerSaveBlocker
);
let systemTrayService: SystemTrayService | undefined;
const systemTraySettingCache = new SystemTraySettingCache(
sql,
@ -761,6 +767,8 @@ ipc.on('title-bar-double-click', () => {
});
ipc.on('set-is-call-active', (_event, isCallActive) => {
preventDisplaySleepService.setEnabled(isCallActive);
if (!mainWindow) {
return;
}