mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 01:03:35 +00:00
[PM-18812] Avoid unnecessary I/O for frequently updated state accountProfile (#14061)
* [PM-18812] Add shouldUpdate checks to frequently-updated state for 'accountProfile' * [PM-18812] Add shouldUpdate checks to frequently-updated state for 'accountProfile' --------- Co-authored-by: Jonas Hendrickx <jhendrickx@bitwarden.com>
This commit is contained in:
@@ -54,12 +54,20 @@ export class DefaultBillingAccountProfileStateService implements BillingAccountP
|
||||
hasPremiumFromAnyOrganization: boolean,
|
||||
userId: UserId,
|
||||
): Promise<void> {
|
||||
await this.stateProvider.getUser(userId, BILLING_ACCOUNT_PROFILE_KEY_DEFINITION).update((_) => {
|
||||
return {
|
||||
hasPremiumPersonally: hasPremiumPersonally,
|
||||
hasPremiumFromAnyOrganization: hasPremiumFromAnyOrganization,
|
||||
};
|
||||
});
|
||||
await this.stateProvider.getUser(userId, BILLING_ACCOUNT_PROFILE_KEY_DEFINITION).update(
|
||||
(_) => {
|
||||
return {
|
||||
hasPremiumPersonally: hasPremiumPersonally,
|
||||
hasPremiumFromAnyOrganization: hasPremiumFromAnyOrganization,
|
||||
};
|
||||
},
|
||||
{
|
||||
shouldUpdate: (state) =>
|
||||
state == null ||
|
||||
state.hasPremiumFromAnyOrganization !== hasPremiumFromAnyOrganization ||
|
||||
state.hasPremiumPersonally !== hasPremiumPersonally,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
canViewSubscription$(userId: UserId): Observable<boolean> {
|
||||
|
||||
Reference in New Issue
Block a user