mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 14:23:32 +00:00
Fix active account and searchBar observables/subscriptions (#3268)
* Change subscription to rely on observables and not on BehaviourSubject * Ensure OnDestroy is added to AppComponent * Fix check for no active accounts to redirect to the login page instead of lock * Change subscription handling on SearchBarService * Fix naming convention: Observables should have a $ suffix * Remove obsolete linter hint * Fix activeAccountUnlocked getting exposed as Observable but is instantiated as BehaviourSubject
This commit is contained in:
committed by
GitHub
parent
c4f9c2cca6
commit
cfc8858ef9
@@ -1,5 +1,6 @@
|
||||
import { Directive, NgZone, OnInit } from "@angular/core";
|
||||
import { Directive, NgZone, OnDestroy, OnInit } from "@angular/core";
|
||||
import { Router } from "@angular/router";
|
||||
import { Subscription } from "rxjs";
|
||||
import { take } from "rxjs/operators";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
@@ -20,7 +21,7 @@ import { SymmetricCryptoKey } from "@bitwarden/common/models/domain/symmetricCry
|
||||
import { SecretVerificationRequest } from "@bitwarden/common/models/request/secretVerificationRequest";
|
||||
|
||||
@Directive()
|
||||
export class LockComponent implements OnInit {
|
||||
export class LockComponent implements OnInit, OnDestroy {
|
||||
masterPassword = "";
|
||||
pin = "";
|
||||
showPassword = false;
|
||||
@@ -39,6 +40,8 @@ export class LockComponent implements OnInit {
|
||||
private invalidPinAttempts = 0;
|
||||
private pinSet: [boolean, boolean];
|
||||
|
||||
private activeAccountSubscription: Subscription;
|
||||
|
||||
constructor(
|
||||
protected router: Router,
|
||||
protected i18nService: I18nService,
|
||||
@@ -57,11 +60,15 @@ export class LockComponent implements OnInit {
|
||||
async ngOnInit() {
|
||||
// Load the first and observe updates
|
||||
await this.load();
|
||||
this.stateService.activeAccount.subscribe(async () => {
|
||||
this.activeAccountSubscription = this.stateService.activeAccount$.subscribe(async () => {
|
||||
await this.load();
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.activeAccountSubscription.unsubscribe();
|
||||
}
|
||||
|
||||
async submit() {
|
||||
if (this.pinLock && (this.pin == null || this.pin === "")) {
|
||||
this.platformUtilsService.showToast(
|
||||
|
||||
Reference in New Issue
Block a user