1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-18 02:41:15 +02:00

refresh ciphers list on add/edit/delete

This commit is contained in:
Kyle Spearrin 2018-01-31 17:20:27 -05:00
parent 16450f3ba9
commit 59726ad818
3 changed files with 7 additions and 26 deletions

View File

@ -142,6 +142,7 @@ export class AddEditComponent implements OnChanges {
try { try {
this.formPromise = this.cipherService.saveWithServer(cipher); this.formPromise = this.cipherService.saveWithServer(cipher);
await this.formPromise; await this.formPromise;
this.cipher.id = cipher.id;
this.analytics.eventTrack.next({ action: this.editMode ? 'Edited Cipher' : 'Added Cipher' }); this.analytics.eventTrack.next({ action: this.editMode ? 'Edited Cipher' : 'Added Cipher' });
this.toasterService.popAsync('success', null, this.i18nService.t(this.editMode ? 'editedItem' : 'addedItem')); this.toasterService.popAsync('success', null, this.i18nService.t(this.editMode ? 'editedItem' : 'addedItem'));
this.onSavedCipher.emit(this.cipher); this.onSavedCipher.emit(this.cipher);

View File

@ -4,7 +4,6 @@ import {
Component, Component,
EventEmitter, EventEmitter,
Input, Input,
OnInit,
Output, Output,
} from '@angular/core'; } from '@angular/core';
@ -16,7 +15,7 @@ import { CipherService } from 'jslib/abstractions/cipher.service';
selector: 'app-vault-ciphers', selector: 'app-vault-ciphers',
template: template, template: template,
}) })
export class CiphersComponent implements OnInit { export class CiphersComponent {
@Input() activeCipherId: string = null; @Input() activeCipherId: string = null;
@Output() onCipherClicked = new EventEmitter<CipherView>(); @Output() onCipherClicked = new EventEmitter<CipherView>();
@Output() onAddCipher = new EventEmitter(); @Output() onAddCipher = new EventEmitter();
@ -26,12 +25,7 @@ export class CiphersComponent implements OnInit {
searchPlaceholder: string = null; searchPlaceholder: string = null;
private filter: (cipher: CipherView) => boolean = null; private filter: (cipher: CipherView) => boolean = null;
constructor(private cipherService: CipherService) { constructor(private cipherService: CipherService) {}
}
async ngOnInit() {
//await this.load();
}
async load(filter: (cipher: CipherView) => boolean = null) { async load(filter: (cipher: CipherView) => boolean = null) {
this.filter = filter; this.filter = filter;
@ -48,20 +42,6 @@ export class CiphersComponent implements OnInit {
await this.load(this.filter); await this.load(this.filter);
} }
updateCipher(cipher: CipherView) {
const i = this.ciphers.findIndex((c) => c.id === cipher.id);
if (i > -1) {
this.ciphers[i] = cipher;
}
}
removeCipher(cipherId: string) {
const i = this.ciphers.findIndex((c) => c.id === cipherId);
if (i > -1) {
this.ciphers.splice(i, 1);
}
}
cipherClicked(cipher: CipherView) { cipherClicked(cipher: CipherView) {
this.onCipherClicked.emit(cipher); this.onCipherClicked.emit(cipher);
} }

View File

@ -119,18 +119,18 @@ export class VaultComponent implements OnInit {
this.go(); this.go();
} }
savedCipher(cipher: CipherView) { async savedCipher(cipher: CipherView) {
this.cipherId = cipher.id; this.cipherId = cipher.id;
this.action = 'view'; this.action = 'view';
this.go(); this.go();
this.ciphersComponent.updateCipher(cipher); await this.ciphersComponent.refresh();
} }
deletedCipher(cipher: CipherView) { async deletedCipher(cipher: CipherView) {
this.cipherId = null; this.cipherId = null;
this.action = null; this.action = null;
this.go(); this.go();
this.ciphersComponent.removeCipher(cipher.id); await this.ciphersComponent.refresh();
} }
editCipherAttachments(cipher: CipherView) { editCipherAttachments(cipher: CipherView) {