From 1794ecd52022f27d5015dea5d620ade5a8d0c5e6 Mon Sep 17 00:00:00 2001 From: Klassare <31806893+klassare@users.noreply.github.com> Date: Mon, 22 Jan 2024 18:33:41 +0100 Subject: [PATCH] drop outdated torusLookup results --- .../send/prepare/prepare-send.component.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/app/components/modals/send/prepare/prepare-send.component.ts b/src/app/components/modals/send/prepare/prepare-send.component.ts index 48b128e7..5df4b648 100644 --- a/src/app/components/modals/send/prepare/prepare-send.component.ts +++ b/src/app/components/modals/send/prepare/prepare-send.component.ts @@ -548,10 +548,12 @@ export class PrepareSendComponent extends ModalComponent implements OnInit, OnCh // resimulate? } async torusLookup(): Promise { + const lookupInput = `${this.torusVerifier}:${this.toPkh}`; + let formInvalid = ''; if (!this.torusService.verifierMapKeys.includes(this.torusVerifier) && this.torusVerifier !== 'domain') { - this.formInvalid = 'Invalid verifier'; + formInvalid = 'Invalid verifier'; } else if (this.invalidTorusAccount()) { - this.formInvalid = this.invalidTorusAccount(); + formInvalid = this.invalidTorusAccount(); } else if (this.toPkh) { this.torusPendingLookup = true; this.torusLookupId = this.toPkh; @@ -562,21 +564,25 @@ export class PrepareSendComponent extends ModalComponent implements OnInit, OnCh .getAddressFromDomain(this.toPkh) .then((ans) => { if (ans?.pkh === '') { - this.formInvalid = 'Could not find the domain'; + formInvalid = 'Could not find the domain'; } return ans; }) .catch((e) => { console.error(e); - this.formInvalid = e; + formInvalid = e; return ''; }) : await this.torusService.lookupPkh(this.torusVerifier, this.toPkh).catch((e) => { console.error(e); - this.formInvalid = e; + formInvalid = e; return ''; }); - + if (lookupInput !== `${this.torusVerifier}:${this.toPkh}`) { + // Lookup input values have changed. So we can ignore this response from lookupPkh(). + return; + } + this.formInvalid = formInvalid; this.torusPendingLookup = false; if (pkh) { this.torusLookupAddress = pkh;