mirror of
https://github.com/bitwarden/browser
synced 2026-02-09 13:10:17 +00:00
Only pass necessary service to power-monitor
PowerMonitorMain only requires the messagingService instead of a full reference to Main
This commit is contained in:
@@ -107,12 +107,12 @@ export class Main {
|
||||
this.messagingMain = new MessagingMain(this, this.stateService);
|
||||
this.updaterMain = new UpdaterMain(this.i18nService, this.windowMain, "bitwarden");
|
||||
this.menuMain = new MenuMain(this);
|
||||
this.powerMonitorMain = new PowerMonitorMain(this);
|
||||
this.trayMain = new TrayMain(this.windowMain, this.i18nService, this.stateService);
|
||||
|
||||
this.messagingService = new ElectronMainMessagingService(this.windowMain, (message) => {
|
||||
this.messagingMain.onMessage(message);
|
||||
});
|
||||
this.powerMonitorMain = new PowerMonitorMain(this.messagingService);
|
||||
|
||||
if (process.platform === "win32") {
|
||||
// eslint-disable-next-line
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { powerMonitor } from "electron";
|
||||
|
||||
import { Main } from "../main";
|
||||
import { ElectronMainMessagingService } from "../services/electron-main-messaging.service";
|
||||
import { isSnapStore } from "../utils";
|
||||
|
||||
// tslint:disable-next-line
|
||||
@@ -10,21 +10,21 @@ const IdleCheckInterval = 30 * 1000; // 30 seconds
|
||||
export class PowerMonitorMain {
|
||||
private idle = false;
|
||||
|
||||
constructor(private main: Main) {}
|
||||
constructor(private messagingService: ElectronMainMessagingService) {}
|
||||
|
||||
init() {
|
||||
// ref: https://github.com/electron/electron/issues/13767
|
||||
if (!isSnapStore()) {
|
||||
// System sleep
|
||||
powerMonitor.on("suspend", () => {
|
||||
this.main.messagingService.send("systemSuspended");
|
||||
this.messagingService.send("systemSuspended");
|
||||
});
|
||||
}
|
||||
|
||||
if (process.platform !== "linux") {
|
||||
// System locked
|
||||
powerMonitor.on("lock-screen", () => {
|
||||
this.main.messagingService.send("systemLocked");
|
||||
this.messagingService.send("systemLocked");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ export class PowerMonitorMain {
|
||||
return;
|
||||
}
|
||||
|
||||
this.main.messagingService.send("systemIdle");
|
||||
this.messagingService.send("systemIdle");
|
||||
}
|
||||
|
||||
this.idle = idle;
|
||||
|
||||
Reference in New Issue
Block a user