1
0
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:
Jonas Hendrickx
2025-05-08 15:19:03 +02:00
committed by GitHub
parent 8ecb32f30f
commit 5943a00afd

View File

@@ -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> {