From e7fc65b6993afc251c4e01870c966d32cd3d361c Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Wed, 8 Feb 2023 11:59:25 +0100 Subject: [PATCH] Only pass necessary service to power-monitor PowerMonitorMain only requires the messagingService instead of a full reference to Main --- apps/desktop/src/main.ts | 2 +- apps/desktop/src/main/power-monitor.main.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts index f5a078cdcc5..b5090c23696 100644 --- a/apps/desktop/src/main.ts +++ b/apps/desktop/src/main.ts @@ -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 diff --git a/apps/desktop/src/main/power-monitor.main.ts b/apps/desktop/src/main/power-monitor.main.ts index 56e6139ccf1..067a380ba05 100644 --- a/apps/desktop/src/main/power-monitor.main.ts +++ b/apps/desktop/src/main/power-monitor.main.ts @@ -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;