From e3950697a4f8c0b3f2abbe8f7f2a29bf5d486488 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 19 Feb 2026 21:15:53 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20cache=20domain=20search=20r?= =?UTF-8?q?esults=20to=20reduce=20API=20calls?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: yeboster <23556525+yeboster@users.noreply.github.com> --- src/components/DomainPayment.svelte | 2 +- src/routes/DomainSearch.svelte | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/components/DomainPayment.svelte b/src/components/DomainPayment.svelte index e04970d..aa60faf 100644 --- a/src/components/DomainPayment.svelte +++ b/src/components/DomainPayment.svelte @@ -51,7 +51,7 @@ years += amount; } - async function handleApproveError(error: Error) { + async function handleApproveError(error: unknown) { let message; if (error instanceof InsufficientBalanceError) message = { diff --git a/src/routes/DomainSearch.svelte b/src/routes/DomainSearch.svelte index 53d006f..606934d 100644 --- a/src/routes/DomainSearch.svelte +++ b/src/routes/DomainSearch.svelte @@ -7,6 +7,7 @@ import IconButton from '@smui/icon-button'; import { metaNamesSdk } from '$lib/stores/sdk'; import { goto } from '$app/navigation'; + import { onDestroy } from 'svelte'; import Icon from 'src/components/Icon.svelte'; const validator = $metaNamesSdk.domainRepository.domainValidator; @@ -17,6 +18,10 @@ let isLoading: boolean = false; let debounceTimer: ReturnType; let requestId = 0; + // Cache for domain search results to prevent redundant API calls + const cache = new Map(); + + onDestroy(() => clearTimeout(debounceTimer)); $: errors = invalid ? validator.getErrors() : []; $: invalid = domainName !== '' && !validator.validate(domainName, { raiseError: false }); @@ -42,11 +47,20 @@ const currentRequestId = ++requestId; nameSearched = domainName.toLocaleLowerCase(); + + // Check cache first to avoid unnecessary network request + if (cache.has(nameSearched)) { + domain = cache.get(nameSearched); + isLoading = false; + return; + } + isLoading = true; const result = await $metaNamesSdk.domainRepository.find(domainName); if (currentRequestId === requestId) { + cache.set(nameSearched, result); domain = result; isLoading = false; }