1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 15:53:27 +00:00

[PM-1400] Update IconComponent to use OnPush ChangeDetection (#5181)

* Add disableFavicon$ to stateService

* Change IconComponent's ChangeDetectionStrategy and use disableFavicon$ observable

* Only get first result from disableFavicon observable

* Move disabledFavicon$ to SettingsService

* Update usage of disableFavicon to use SettingsService

* Remove getting and setting of disabledFavicon on login

* Settings service observable adjustments

* Fix for popup initially having a null value for the disableFavicon setting in settingsService

* Move disabledFavicon$ subscription to ngOnInit

* feat: experiment with observables

* Remove SettingsService from browser app component

* Fix storybook changes

* Update apps/web/src/app/vault/components/vault-items/vault-items.stories.ts

Co-authored-by: Andreas Coroiu <acoroiu@bitwarden.com>

* Fix mock function signature

---------

Co-authored-by: Andreas Coroiu <andreas.coroiu@gmail.com>
Co-authored-by: Andreas Coroiu <acoroiu@bitwarden.com>
This commit is contained in:
Robyn MacCallum
2023-04-28 15:07:26 -04:00
committed by GitHub
parent a899ea370e
commit 671a9115bb
15 changed files with 164 additions and 109 deletions

View File

@@ -3,6 +3,7 @@ import { Component, OnInit } from "@angular/core";
import { AbstractThemingService } from "@bitwarden/angular/services/theming/theming.service.abstraction";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
import { SettingsService } from "@bitwarden/common/abstractions/settings.service";
import { StateService } from "@bitwarden/common/abstractions/state.service";
import { TotpService } from "@bitwarden/common/abstractions/totp.service";
import { ThemeType, UriMatchType } from "@bitwarden/common/enums";
@@ -39,7 +40,8 @@ export class OptionsComponent implements OnInit {
private stateService: StateService,
private totpService: TotpService,
i18nService: I18nService,
private themingService: AbstractThemingService
private themingService: AbstractThemingService,
private settingsService: SettingsService
) {
this.themeOptions = [
{ name: i18nService.t("default"), value: ThemeType.System },
@@ -89,7 +91,7 @@ export class OptionsComponent implements OnInit {
this.enableAutoTotpCopy = !(await this.stateService.getDisableAutoTotpCopy());
this.enableFavicon = !(await this.stateService.getDisableFavicon());
this.enableFavicon = !this.settingsService.getDisableFavicon();
this.enableBadgeCounter = !(await this.stateService.getDisableBadgeCounter());
@@ -129,7 +131,7 @@ export class OptionsComponent implements OnInit {
}
async updateFavicon() {
await this.stateService.setDisableFavicon(!this.enableFavicon);
await this.settingsService.setDisableFavicon(!this.enableFavicon);
}
async updateBadgeCounter() {

View File

@@ -3,9 +3,13 @@ import { BehaviorSubject } from "rxjs";
import { AccountSettingsSettings } from "@bitwarden/common/models/domain/account";
import { SettingsService } from "@bitwarden/common/services/settings.service";
import { sessionSync } from "../decorators/session-sync-observable";
import { browserSession, sessionSync } from "../decorators/session-sync-observable";
@browserSession
export class BrowserSettingsService extends SettingsService {
@sessionSync({ initializer: (obj: string[][]) => obj })
protected _settings: BehaviorSubject<AccountSettingsSettings>;
@sessionSync({ initializer: (b: boolean) => b })
protected _disableFavicon: BehaviorSubject<boolean>;
}