mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-29 12:55:21 +01:00
Fixed race condition where this.canAccessPremium would be undefined before the sync could complete (#8887)
This commit is contained in:
parent
6b0628b81e
commit
790c9a6141
@ -9,7 +9,7 @@ import {
|
|||||||
OnInit,
|
OnInit,
|
||||||
Output,
|
Output,
|
||||||
} from "@angular/core";
|
} from "@angular/core";
|
||||||
import { firstValueFrom, Subject, takeUntil } from "rxjs";
|
import { firstValueFrom } from "rxjs";
|
||||||
|
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
||||||
@ -69,7 +69,6 @@ export class ViewComponent implements OnDestroy, OnInit {
|
|||||||
private totpInterval: any;
|
private totpInterval: any;
|
||||||
private previousCipherId: string;
|
private previousCipherId: string;
|
||||||
private passwordReprompted = false;
|
private passwordReprompted = false;
|
||||||
private directiveIsDestroyed$ = new Subject<boolean>();
|
|
||||||
|
|
||||||
get fido2CredentialCreationDateValue(): string {
|
get fido2CredentialCreationDateValue(): string {
|
||||||
const dateCreated = this.i18nService.t("dateCreated");
|
const dateCreated = this.i18nService.t("dateCreated");
|
||||||
@ -119,19 +118,11 @@ export class ViewComponent implements OnDestroy, OnInit {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
this.billingAccountProfileStateService.hasPremiumFromAnySource$
|
|
||||||
.pipe(takeUntil(this.directiveIsDestroyed$))
|
|
||||||
.subscribe((canAccessPremium: boolean) => {
|
|
||||||
this.canAccessPremium = canAccessPremium;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.broadcasterService.unsubscribe(BroadcasterSubscriptionId);
|
this.broadcasterService.unsubscribe(BroadcasterSubscriptionId);
|
||||||
this.cleanUp();
|
this.cleanUp();
|
||||||
this.directiveIsDestroyed$.next(true);
|
|
||||||
this.directiveIsDestroyed$.complete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async load() {
|
async load() {
|
||||||
@ -141,6 +132,9 @@ export class ViewComponent implements OnDestroy, OnInit {
|
|||||||
this.cipher = await cipher.decrypt(
|
this.cipher = await cipher.decrypt(
|
||||||
await this.cipherService.getKeyForCipherKeyDecryption(cipher),
|
await this.cipherService.getKeyForCipherKeyDecryption(cipher),
|
||||||
);
|
);
|
||||||
|
this.canAccessPremium = await firstValueFrom(
|
||||||
|
this.billingAccountProfileStateService.hasPremiumFromAnySource$,
|
||||||
|
);
|
||||||
this.showPremiumRequiredTotp =
|
this.showPremiumRequiredTotp =
|
||||||
this.cipher.login.totp && !this.canAccessPremium && !this.cipher.organizationUseTotp;
|
this.cipher.login.totp && !this.canAccessPremium && !this.cipher.organizationUseTotp;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user