From db83cab552296c609bc3dc6841070ec7fa231818 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 5 Apr 2018 23:49:38 -0400 Subject: [PATCH] call into load method --- src/angular/components/add-edit.component.ts | 12 +++++++----- src/angular/components/view.component.ts | 12 ++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/angular/components/add-edit.component.ts b/src/angular/components/add-edit.component.ts index cc05dc6789..91ad981176 100644 --- a/src/angular/components/add-edit.component.ts +++ b/src/angular/components/add-edit.component.ts @@ -1,7 +1,6 @@ import { EventEmitter, Input, - OnChanges, Output, } from '@angular/core'; @@ -28,7 +27,7 @@ import { LoginUriView } from '../../models/view/loginUriView'; import { LoginView } from '../../models/view/loginView'; import { SecureNoteView } from '../../models/view/secureNoteView'; -export class AddEditComponent implements OnChanges { +export class AddEditComponent { @Input() folderId: string; @Input() cipherId: string; @Input() type: CipherType; @@ -116,7 +115,7 @@ export class AddEditComponent implements OnChanges { ]; } - async ngOnChanges() { + async load() { this.editMode = this.cipherId != null; if (this.editMode) { @@ -140,11 +139,11 @@ export class AddEditComponent implements OnChanges { this.folders = await this.folderService.getAllDecrypted(); } - async submit() { + async submit(): Promise { if (this.cipher.name == null || this.cipher.name === '') { this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'), this.i18nService.t('nameRequired')); - return; + return false; } const cipher = await this.cipherService.encrypt(this.cipher); @@ -157,7 +156,10 @@ export class AddEditComponent implements OnChanges { this.toasterService.popAsync('success', null, this.i18nService.t(this.editMode ? 'editedItem' : 'addedItem')); this.onSavedCipher.emit(this.cipher); + return true; } catch { } + + return false; } addUri() { diff --git a/src/angular/components/view.component.ts b/src/angular/components/view.component.ts index ef9d52f346..dc3a1e8d19 100644 --- a/src/angular/components/view.component.ts +++ b/src/angular/components/view.component.ts @@ -25,7 +25,7 @@ import { CipherView } from '../../models/view/cipherView'; import { FieldView } from '../../models/view/fieldView'; import { LoginUriView } from '../../models/view/loginUriView'; -export class ViewComponent implements OnChanges, OnDestroy { +export class ViewComponent implements OnDestroy { @Input() cipherId: string; @Output() onEditCipher = new EventEmitter(); @@ -48,7 +48,11 @@ export class ViewComponent implements OnChanges, OnDestroy { protected i18nService: I18nService, protected analytics: Angulartics2, protected auditService: AuditService) { } - async ngOnChanges() { + ngOnDestroy() { + this.cleanUp(); + } + + async load() { this.cleanUp(); const cipher = await this.cipherService.get(this.cipherId); @@ -67,10 +71,6 @@ export class ViewComponent implements OnChanges, OnDestroy { } } - ngOnDestroy() { - this.cleanUp(); - } - edit() { this.onEditCipher.emit(this.cipher); }