diff --git a/src/app/accounts/lock.component.ts b/src/app/accounts/lock.component.ts index 8603d67bff..d0ebe32eb6 100644 --- a/src/app/accounts/lock.component.ts +++ b/src/app/accounts/lock.component.ts @@ -1,5 +1,6 @@ import { Component, + OnDestroy, NgZone, } from '@angular/core'; import { @@ -28,7 +29,7 @@ const BroadcasterSubscriptionId = 'LockComponent'; selector: 'app-lock', templateUrl: 'lock.component.html', }) -export class LockComponent extends BaseLockComponent { +export class LockComponent extends BaseLockComponent implements OnDestroy { constructor(router: Router, i18nService: I18nService, platformUtilsService: PlatformUtilsService, messagingService: MessagingService, userService: UserService, cryptoService: CryptoService, @@ -59,6 +60,10 @@ export class LockComponent extends BaseLockComponent { }); } + ngOnDestroy() { + this.broadcasterService.unsubscribe(BroadcasterSubscriptionId); + } + onWindowHidden() { this.showPassword = false; } diff --git a/src/app/accounts/login.component.ts b/src/app/accounts/login.component.ts index 013aba98f8..d0d0ba0b13 100644 --- a/src/app/accounts/login.component.ts +++ b/src/app/accounts/login.component.ts @@ -1,6 +1,7 @@ import { Component, ComponentFactoryResolver, + OnDestroy, NgZone, ViewChild, ViewContainerRef, @@ -31,7 +32,7 @@ const BroadcasterSubscriptionId = 'LoginComponent'; selector: 'app-login', templateUrl: 'login.component.html', }) -export class LoginComponent extends BaseLoginComponent { +export class LoginComponent extends BaseLoginComponent implements OnDestroy { @ViewChild('environment', { read: ViewContainerRef, static: true }) environmentModal: ViewContainerRef; showingModal = false; @@ -63,6 +64,10 @@ export class LoginComponent extends BaseLoginComponent { }); } + ngOnDestroy() { + this.broadcasterService.unsubscribe(BroadcasterSubscriptionId); + } + settings() { const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent); const modal = this.environmentModal.createComponent(factory).instance; diff --git a/src/app/accounts/register.component.ts b/src/app/accounts/register.component.ts index 3c7fd8f826..c2e26bb916 100644 --- a/src/app/accounts/register.component.ts +++ b/src/app/accounts/register.component.ts @@ -1,5 +1,6 @@ import { Component, + OnDestroy, OnInit, NgZone, } from '@angular/core'; @@ -23,7 +24,7 @@ const BroadcasterSubscriptionId = 'RegisterComponent'; selector: 'app-register', templateUrl: 'register.component.html', }) -export class RegisterComponent extends BaseRegisterComponent implements OnInit { +export class RegisterComponent extends BaseRegisterComponent implements OnInit, OnDestroy { constructor(authService: AuthService, router: Router, i18nService: I18nService, cryptoService: CryptoService, apiService: ApiService, stateService: StateService, @@ -46,6 +47,10 @@ export class RegisterComponent extends BaseRegisterComponent implements OnInit { }); } + ngOnDestroy() { + this.broadcasterService.unsubscribe(BroadcasterSubscriptionId); + } + onWindowHidden() { this.showPassword = false; } diff --git a/src/app/accounts/set-password.component.ts b/src/app/accounts/set-password.component.ts index d7e186b090..b412c5b515 100644 --- a/src/app/accounts/set-password.component.ts +++ b/src/app/accounts/set-password.component.ts @@ -1,5 +1,6 @@ import { Component, + OnDestroy, NgZone, } from '@angular/core'; @@ -30,7 +31,7 @@ import { selector: 'app-set-password', templateUrl: 'set-password.component.html', }) -export class SetPasswordComponent extends BaseSetPasswordComponent { +export class SetPasswordComponent extends BaseSetPasswordComponent implements OnDestroy { constructor(apiService: ApiService, i18nService: I18nService, cryptoService: CryptoService, messagingService: MessagingService, userService: UserService, passwordGenerationService: PasswordGenerationService, @@ -85,6 +86,10 @@ export class SetPasswordComponent extends BaseSetPasswordComponent { }); } + ngOnDestroy() { + this.broadcasterService.unsubscribe(BroadcasterSubscriptionId); + } + onWindowHidden() { this.showPassword = false; } diff --git a/src/app/vault/add-edit.component.ts b/src/app/vault/add-edit.component.ts index 4571223c0f..2fb79fd7e0 100644 --- a/src/app/vault/add-edit.component.ts +++ b/src/app/vault/add-edit.component.ts @@ -1,6 +1,7 @@ import { Component, OnChanges, + OnDestroy, NgZone, } from '@angular/core'; @@ -25,7 +26,7 @@ const BroadcasterSubscriptionId = 'AddEditComponent'; selector: 'app-vault-add-edit', templateUrl: 'add-edit.component.html', }) -export class AddEditComponent extends BaseAddEditComponent implements OnChanges { +export class AddEditComponent extends BaseAddEditComponent implements OnChanges, OnDestroy { constructor(cipherService: CipherService, folderService: FolderService, i18nService: I18nService, platformUtilsService: PlatformUtilsService, auditService: AuditService, stateService: StateService, @@ -55,6 +56,10 @@ export class AddEditComponent extends BaseAddEditComponent implements OnChanges await this.load(); } + ngOnDestroy() { + this.broadcasterService.unsubscribe(BroadcasterSubscriptionId); + } + async load() { if (document.querySelectorAll('app-vault-add-edit .ng-dirty').length === 0 || (this.cipher != null && this.cipherId !== this.cipher.id)) { diff --git a/src/app/vault/export.component.ts b/src/app/vault/export.component.ts index 0e563e9e01..8d42599f18 100644 --- a/src/app/vault/export.component.ts +++ b/src/app/vault/export.component.ts @@ -1,5 +1,6 @@ import { Component, + OnDestroy, OnInit, NgZone, } from '@angular/core'; @@ -41,6 +42,10 @@ export class ExportComponent extends BaseExportComponent implements OnInit { }); } + ngOnDestroy() { + this.broadcasterService.unsubscribe(BroadcasterSubscriptionId); + } + onWindowHidden() { this.showPassword = false; } diff --git a/src/app/vault/view.component.ts b/src/app/vault/view.component.ts index 0ba3a5cd07..f8e411d908 100644 --- a/src/app/vault/view.component.ts +++ b/src/app/vault/view.component.ts @@ -58,6 +58,11 @@ export class ViewComponent extends BaseViewComponent implements OnChanges { }); } + ngOnDestroy() { + super.ngOnDestroy(); + this.broadcasterService.unsubscribe(BroadcasterSubscriptionId); + } + async ngOnChanges() { await super.load(); }