1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 08:43:33 +00:00

[PM-5540] DesktopSettingsService (#8369)

* WIP: First Try at making DesktopSettingsService

Does not work, migrations are ran in renderer but the values are read in main.

* Update window$ retrieval

* Fix DesktopSettings

* Rename Migration

* Add Migration to Builder

* Cleanup

* Update Comments

* Update `migrate.ts`

* Catch Unawaited Promises

* Remove Comments

* Update Tests

* Rename Migration

* Add `alwaysOnTop`

* Make `init` async

* Fix Desktop Build
This commit is contained in:
Justin Baur
2024-03-21 12:53:12 -05:00
committed by GitHub
parent b9f9ad029f
commit b450b31ec4
15 changed files with 459 additions and 263 deletions

View File

@@ -57,8 +57,8 @@ export class Main {
environmentService: DefaultEnvironmentService;
mainCryptoFunctionService: MainCryptoFunctionService;
desktopCredentialStorageListener: DesktopCredentialStorageListener;
migrationRunner: MigrationRunner;
desktopSettingsService: DesktopSettingsService;
migrationRunner: MigrationRunner;
tokenService: TokenServiceAbstraction;
windowMain: WindowMain;
@@ -179,6 +179,8 @@ export class Main {
false, // Do not use disk caching because this will get out of sync with the renderer service
);
this.desktopSettingsService = new DesktopSettingsService(stateProvider);
const biometricStateService = new DefaultBiometricStateService(stateProvider);
this.windowMain = new WindowMain(
@@ -186,13 +188,13 @@ export class Main {
biometricStateService,
this.logService,
this.storageService,
this.desktopSettingsService,
(arg) => this.processDeepLink(arg),
(win) => this.trayMain.setupWindowListeners(win),
);
this.messagingMain = new MessagingMain(this, this.stateService);
this.messagingMain = new MessagingMain(this, this.stateService, this.desktopSettingsService);
this.updaterMain = new UpdaterMain(this.i18nService, this.windowMain);
this.trayMain = new TrayMain(this.windowMain, this.i18nService, this.stateService);
this.desktopSettingsService = new DesktopSettingsService(stateProvider);
this.trayMain = new TrayMain(this.windowMain, this.i18nService, this.desktopSettingsService);
this.messagingService = new ElectronMainMessagingService(this.windowMain, (message) => {
this.messagingMain.onMessage(message);
@@ -244,7 +246,7 @@ export class Main {
await this.toggleHardwareAcceleration();
await this.windowMain.init();
await this.i18nService.init();
this.messagingMain.init();
await this.messagingMain.init();
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.menuMain.init();
@@ -256,10 +258,8 @@ export class Main {
click: () => this.messagingService.send("lockVault"),
},
]);
if (await this.stateService.getEnableStartToTray()) {
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.trayMain.hideToTray();
if (await firstValueFrom(this.desktopSettingsService.startToTray$)) {
await this.trayMain.hideToTray();
}
this.powerMonitorMain.init();
await this.updaterMain.init();