mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 17:53:39 +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:
@@ -7,8 +7,10 @@ import { AccountSettingsSettings } from "../models/domain/account";
|
||||
|
||||
export class SettingsService implements SettingsServiceAbstraction {
|
||||
protected _settings: BehaviorSubject<AccountSettingsSettings> = new BehaviorSubject({});
|
||||
protected _disableFavicon = new BehaviorSubject<boolean>(null);
|
||||
|
||||
settings$ = this._settings.asObservable();
|
||||
disableFavicon$ = this._disableFavicon.asObservable();
|
||||
|
||||
constructor(private stateService: StateService) {
|
||||
this.stateService.activeAccountUnlocked$
|
||||
@@ -24,8 +26,10 @@ export class SettingsService implements SettingsServiceAbstraction {
|
||||
}
|
||||
|
||||
const data = await this.stateService.getSettings();
|
||||
const disableFavicon = await this.stateService.getDisableFavicon();
|
||||
|
||||
this._settings.next(data);
|
||||
this._disableFavicon.next(disableFavicon);
|
||||
})
|
||||
)
|
||||
.subscribe();
|
||||
@@ -61,6 +65,15 @@ export class SettingsService implements SettingsServiceAbstraction {
|
||||
return new Set(result);
|
||||
}
|
||||
|
||||
async setDisableFavicon(value: boolean) {
|
||||
this._disableFavicon.next(value);
|
||||
await this.stateService.setDisableFavicon(value);
|
||||
}
|
||||
|
||||
getDisableFavicon(): boolean {
|
||||
return this._disableFavicon.getValue();
|
||||
}
|
||||
|
||||
async clear(userId?: string): Promise<void> {
|
||||
if (userId == null || userId == (await this.stateService.getUserId())) {
|
||||
this._settings.next({});
|
||||
|
||||
@@ -103,7 +103,6 @@ export class StateService<
|
||||
} else if (userId == null) {
|
||||
this.activeAccountUnlockedSubject.next(false);
|
||||
}
|
||||
|
||||
// FIXME: This should be refactored into AuthService or a similar service,
|
||||
// as checking for the existence of the crypto key is a low level
|
||||
// implementation detail.
|
||||
@@ -130,6 +129,7 @@ export class StateService<
|
||||
}
|
||||
});
|
||||
await this.initAccountState();
|
||||
|
||||
this.hasBeenInited = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user