Skip to content

Commit

Permalink
Fix slow load of long list of addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
JST5000 committed Jan 3, 2024
1 parent 3201a24 commit b07ff34
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
25 changes: 15 additions & 10 deletions content/resources/dev-tools/toml-checker/ListTomlFields.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { clsx } from 'clsx'
import { Client } from 'xrpl'

// Decode a hexadecimal string into a regular string, assuming 8-bit characters.
// Not proper unicode decoding, but it'll work for domains which are supposed

import React = require("react");
import { CLASS_GOOD } from "../components/LogEntry";
import { AccountFields } from "./XrplToml";

// Decode a hexadecimal string into a regular string, assuming 8-bit characters.
// Not proper unicode decoding, but it'll work for domains which are supposed
// to be a subset of ASCII anyway.
function decodeHex(hex) {
let str = '';
Expand Down Expand Up @@ -135,19 +133,26 @@ export async function getListEntries(fields: Object[], filter?: Function, domain
})

const key = `entry-${formattedEntries.length}`
const promises = []
if(domainToVerify) {
const accountEntry = entry as AccountFields
if(accountEntry.address) {
const net = accountEntry.network ?? "main"
const domainIsValid = await validateAddressDomainOnNet(accountEntry.address, domainToVerify, net)
const domainIsValid = validateAddressDomainOnNet(accountEntry.address, domainToVerify, net)

if(domainIsValid) {
displayedFields.push(
<li className={CLASS_GOOD} key={`${key}-result`}>DOMAIN VALIDATED <i className="fa fa-check-circle"/></li>
)
}
domainIsValid.then((wasValidated) => {
if(wasValidated) {
displayedFields.push(
<li className={CLASS_GOOD} key={`${key}-result`}>DOMAIN VALIDATED <i className="fa fa-check-circle"/></li>
)
}
})

promises.push(domainIsValid)
}
}

await Promise.all(promises)

formattedEntries.push((<li key={key}>
<ul className={clsx(domainToVerify && 'mb-3')} key={key + "-ul"}>{displayedFields}</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async function validateAndDisplayFields(
status: {
followUpMessage: (
<ol>
{formattedEntries}
{formattedEntries}
</ol>
),
icon: icon
Expand Down

0 comments on commit b07ff34

Please sign in to comment.