Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/routes/DomainSearch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
let domainName: string = '';
let nameSearched: string = '';
let isLoading: boolean = false;
let debounceTimer: NodeJS.Timeout;
let debounceTimer: ReturnType<typeof setTimeout>;

$: errors = invalid ? validator.getErrors() : [];
$: invalid = domainName !== '' && !validator.validate(domainName, { raiseError: false });
Expand All @@ -36,12 +36,22 @@
return goto(url);
}

nameSearched = domainName.toLocaleLowerCase();
const currentName = domainName.toLocaleLowerCase();
if (!submit && currentName === nameSearched) return;

nameSearched = currentName;
isLoading = true;

domain = await $metaNamesSdk.domainRepository.find(domainName);
try {
const result = await $metaNamesSdk.domainRepository.find(domainName);
if (currentName !== nameSearched) return;

isLoading = false;
domain = result;
isLoading = false;
} catch (error) {
console.error(error);
if (currentName === nameSearched) isLoading = false;
}
}

async function submit() {
Expand All @@ -55,7 +65,7 @@
class="domain-input"
variant="outlined"
bind:value={domainName}
on:keyup={() => debounce()}
on:input={() => debounce()}
bind:invalid
label="Domain name"
withTrailingIcon
Expand Down