diff --git a/src/app/vault/vault.component.ts b/src/app/vault/vault.component.ts index 1cb874f3..0c95efa0 100644 --- a/src/app/vault/vault.component.ts +++ b/src/app/vault/vault.component.ts @@ -46,18 +46,30 @@ export class VaultComponent implements OnInit { } viewCipher(id: string) { + if (this.action === 'view' && this.cipherId === id) { + return; + } + this.cipherId = id; this.action = 'view'; this.go({ action: this.action, cipherId: id }); } editCipher(id: string) { + if (this.action === 'edit' && this.cipherId === id) { + return; + } + this.cipherId = id; this.action = 'edit'; this.go({ action: this.action, cipherId: id }); } addCipher() { + if (this.action === 'add') { + return; + } + this.action = 'add'; this.go({ action: this.action }); } diff --git a/src/app/vault/view.component.ts b/src/app/vault/view.component.ts index 35588f0f..e2b0d722 100644 --- a/src/app/vault/view.component.ts +++ b/src/app/vault/view.component.ts @@ -40,7 +40,7 @@ export class ViewComponent implements OnChanges, OnDestroy { } async ngOnChanges() { - this.showPassword = false; + this.cleanUp(); const cipher = await this.cipherService.get(this.cipherId); this.cipher = await cipher.decrypt(); @@ -52,10 +52,6 @@ export class ViewComponent implements OnChanges, OnDestroy { await this.totpUpdateCode(); await this.totpTick(); - if (this.totpInterval) { - clearInterval(this.totpInterval); - } - this.totpInterval = setInterval(async () => { await this.totpTick(); }, 1000); @@ -63,9 +59,7 @@ export class ViewComponent implements OnChanges, OnDestroy { } ngOnDestroy() { - if (this.totpInterval) { - clearInterval(this.totpInterval); - } + this.cleanUp(); } edit() { @@ -84,6 +78,14 @@ export class ViewComponent implements OnChanges, OnDestroy { // TODO } + private cleanUp() { + this.cipher = null; + this.showPassword = false; + if (this.totpInterval) { + clearInterval(this.totpInterval); + } + } + private async totpUpdateCode() { if (this.cipher.type !== CipherType.Login || this.cipher.login.totp == null) { return; @@ -111,5 +113,4 @@ export class ViewComponent implements OnChanges, OnDestroy { await this.totpUpdateCode(); } } - }