From 456448d7d62c89c5f473393eb4122ca70a165ff2 Mon Sep 17 00:00:00 2001 From: Manuel Wedler Date: Thu, 8 Aug 2024 14:57:53 +0200 Subject: [PATCH] Reset lookup results when chain or contract changes --- .../src/app/views/LookupView.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/contract-verification/src/app/views/LookupView.tsx b/apps/contract-verification/src/app/views/LookupView.tsx index 0dd52306bc..53bf009d42 100644 --- a/apps/contract-verification/src/app/views/LookupView.tsx +++ b/apps/contract-verification/src/app/views/LookupView.tsx @@ -1,4 +1,4 @@ -import { useContext, useState } from 'react' +import { useContext, useEffect, useState } from 'react' import { SearchableChainDropdown, ContractAddressInput } from '../components' import { mergeChainSettingsWithDefaults, validConfiguration } from '../utils' import type { LookupResponse, VerifierIdentifier, Chain } from '../types' @@ -21,7 +21,18 @@ export const LookupView = () => { const submitDisabled = !!contractAddressError || !contractAddress || !selectedChain + // Reset results when chain or contract changes + useEffect(() => { + setLookupResult({}) + setLoadingVerifiers({}) + }, [selectedChain, contractAddress]) + const handleLookup = (e) => { + if (Object.values(loadingVerifiers).some((loading) => loading)) { + console.error('Lookup request already running') + return + } + e.preventDefault() for (const verifierId of VERIFIERS) {