1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 16:53:34 +00:00

[fix] Unsubscribe from activeAccount in AppComponent (#2960)

This commit is contained in:
Addison Beck
2022-06-23 06:38:12 -07:00
committed by GitHub
parent 57b8144013
commit e00fe8edae
2 changed files with 26 additions and 5 deletions

View File

@@ -10,6 +10,7 @@ import {
import { DomSanitizer } from "@angular/platform-browser";
import { Router } from "@angular/router";
import { IndividualConfig, ToastrService } from "ngx-toastr";
import { Subject, takeUntil } from "rxjs";
import { ModalRef } from "@bitwarden/angular/components/modal/modal.ref";
import { ModalService } from "@bitwarden/angular/services/modal.service";
@@ -96,6 +97,8 @@ export class AppComponent implements OnInit {
private isIdle = false;
private activeUserId: string = null;
private destroy$: Subject<void> = new Subject<void>();
constructor(
private broadcasterService: BroadcasterService,
private tokenService: TokenService,
@@ -127,9 +130,10 @@ export class AppComponent implements OnInit {
) {}
ngOnInit() {
this.stateService.activeAccount.subscribe((userId) => {
this.stateService.activeAccount.pipe(takeUntil(this.destroy$)).subscribe((userId) => {
this.activeUserId = userId;
});
this.ngZone.runOutsideAngular(() => {
setTimeout(async () => {
await this.updateAppMenu();
@@ -360,6 +364,8 @@ export class AppComponent implements OnInit {
}
ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
this.broadcasterService.unsubscribe(BroadcasterSubscriptionId);
}