From 24ffb55ce0e781fb06cd04d318e9f70afe80d734 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 24 Jun 2019 21:12:34 -0400 Subject: [PATCH] addEditCipherInfo w/ collections from state --- src/angular/components/add-edit.component.ts | 27 ++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/angular/components/add-edit.component.ts b/src/angular/components/add-edit.component.ts index b04bedc1a..dbfd6b3b3 100644 --- a/src/angular/components/add-edit.component.ts +++ b/src/angular/components/add-edit.component.ts @@ -162,8 +162,13 @@ export class AddEditComponent implements OnInit { this.title = this.i18nService.t('addItem'); } - this.cipher = await this.stateService.get('addEditCipher'); - await this.stateService.remove('addEditCipher'); + const addEditCipherInfo: any = await this.stateService.get('addEditCipherInfo'); + if (addEditCipherInfo != null) { + this.cipher = addEditCipherInfo.cipher; + this.collectionIds = addEditCipherInfo.collectionIds; + } + await this.stateService.remove('addEditCipherInfo'); + if (this.cipher == null) { if (this.editMode) { const cipher = await this.loadCipher(); @@ -179,15 +184,17 @@ export class AddEditComponent implements OnInit { this.cipher.identity = new IdentityView(); this.cipher.secureNote = new SecureNoteView(); this.cipher.secureNote.type = SecureNoteType.Generic; + } + } - await this.organizationChanged(); - if (this.collectionIds != null && this.collectionIds.length > 0 && this.collections.length > 0) { - this.collections.forEach((c) => { - if (this.collectionIds.indexOf(c.id) > -1) { - (c as any).checked = true; - } - }); - } + if (this.cipher != null && (!this.editMode || addEditCipherInfo != null)) { + await this.organizationChanged(); + if (this.collectionIds != null && this.collectionIds.length > 0 && this.collections.length > 0) { + this.collections.forEach((c) => { + if (this.collectionIds.indexOf(c.id) > -1) { + (c as any).checked = true; + } + }); } }