1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-24 12:06:15 +01:00

routing updates

This commit is contained in:
Kyle Spearrin 2018-01-25 11:28:52 -05:00
parent 54c117bdc6
commit 15868ab541
2 changed files with 22 additions and 9 deletions

View File

@ -46,18 +46,30 @@ export class VaultComponent implements OnInit {
} }
viewCipher(id: string) { viewCipher(id: string) {
if (this.action === 'view' && this.cipherId === id) {
return;
}
this.cipherId = id; this.cipherId = id;
this.action = 'view'; this.action = 'view';
this.go({ action: this.action, cipherId: id }); this.go({ action: this.action, cipherId: id });
} }
editCipher(id: string) { editCipher(id: string) {
if (this.action === 'edit' && this.cipherId === id) {
return;
}
this.cipherId = id; this.cipherId = id;
this.action = 'edit'; this.action = 'edit';
this.go({ action: this.action, cipherId: id }); this.go({ action: this.action, cipherId: id });
} }
addCipher() { addCipher() {
if (this.action === 'add') {
return;
}
this.action = 'add'; this.action = 'add';
this.go({ action: this.action }); this.go({ action: this.action });
} }

View File

@ -40,7 +40,7 @@ export class ViewComponent implements OnChanges, OnDestroy {
} }
async ngOnChanges() { async ngOnChanges() {
this.showPassword = false; this.cleanUp();
const cipher = await this.cipherService.get(this.cipherId); const cipher = await this.cipherService.get(this.cipherId);
this.cipher = await cipher.decrypt(); this.cipher = await cipher.decrypt();
@ -52,10 +52,6 @@ export class ViewComponent implements OnChanges, OnDestroy {
await this.totpUpdateCode(); await this.totpUpdateCode();
await this.totpTick(); await this.totpTick();
if (this.totpInterval) {
clearInterval(this.totpInterval);
}
this.totpInterval = setInterval(async () => { this.totpInterval = setInterval(async () => {
await this.totpTick(); await this.totpTick();
}, 1000); }, 1000);
@ -63,9 +59,7 @@ export class ViewComponent implements OnChanges, OnDestroy {
} }
ngOnDestroy() { ngOnDestroy() {
if (this.totpInterval) { this.cleanUp();
clearInterval(this.totpInterval);
}
} }
edit() { edit() {
@ -84,6 +78,14 @@ export class ViewComponent implements OnChanges, OnDestroy {
// TODO // TODO
} }
private cleanUp() {
this.cipher = null;
this.showPassword = false;
if (this.totpInterval) {
clearInterval(this.totpInterval);
}
}
private async totpUpdateCode() { private async totpUpdateCode() {
if (this.cipher.type !== CipherType.Login || this.cipher.login.totp == null) { if (this.cipher.type !== CipherType.Login || this.cipher.login.totp == null) {
return; return;
@ -111,5 +113,4 @@ export class ViewComponent implements OnChanges, OnDestroy {
await this.totpUpdateCode(); await this.totpUpdateCode();
} }
} }
} }