1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

onDestroy needed for broadcast subscriptions

This commit is contained in:
Chad Scharf
2020-11-04 14:00:44 -05:00
parent c9c6a11390
commit 97e982bf01
7 changed files with 40 additions and 5 deletions

View File

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