Debounce name checks

This commit is contained in:
Kieran 2023-01-12 22:46:17 +00:00
parent 26ee939bb1
commit 0d7b60e078
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
2 changed files with 21 additions and 20 deletions

View File

@ -77,6 +77,7 @@ export default function Nip5Service(props: Nip05ServiceProps) {
setAvailabilityResponse({ available: false, why: "REGEX" }); setAvailabilityResponse({ available: false, why: "REGEX" });
return; return;
} }
let t = setTimeout(() => {
svc.CheckAvailable(handle, domain) svc.CheckAvailable(handle, domain)
.then(a => { .then(a => {
if ('error' in a) { if ('error' in a) {
@ -86,6 +87,8 @@ export default function Nip5Service(props: Nip05ServiceProps) {
} }
}) })
.catch(console.error); .catch(console.error);
}, 500);
return () => clearTimeout(t);
} }
}, [handle, domain]); }, [handle, domain]);

View File

@ -86,13 +86,11 @@ export class ServiceProvider {
} }
}); });
if (rsp.ok) {
let obj = await rsp.json(); let obj = await rsp.json();
if ('error' in obj) { if ('error' in obj) {
return <ServiceError>obj; return <ServiceError>obj;
} }
return obj; return obj;
}
} catch (e) { } catch (e) {
console.warn(e); console.warn(e);
} }