Skip to content

Commit

Permalink
fix(ui): ⚡ Improve perceived load time of txs view
Browse files Browse the repository at this point in the history
  • Loading branch information
jojobyte committed Apr 15, 2024
1 parent 8f02376 commit a2db906
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
14 changes: 9 additions & 5 deletions src/helpers/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1800,9 +1800,12 @@ export function processInOut({

export async function getAddrsTransactions({
appState, addrs, contactAddrs = {},
txs = [],
}) {
let storeAddrs = await loadStoreObject(store.addresses)
let txs = await dashsight.getAllTxs(addrs)
if (txs.length === 0) {
txs = await dashsight.getAllTxs(addrs)
}
let byAddress = {}
let byAlias = {}
let byTx = {}
Expand Down Expand Up @@ -1891,8 +1894,8 @@ export async function getContactsByXkeyId(
let contactsXkeys = {}

for await (let c of appState.contacts) {
let og = Object.values(c.outgoing || [])?.[0]
let ic = Object.values(c.incoming || [])?.[0]
let og = Object.values(c.outgoing || {})?.[0]
let ic = Object.values(c.incoming || {})?.[0]

if (og) {
contactsXkeys[og.xkeyId] = {
Expand Down Expand Up @@ -1941,7 +1944,7 @@ export async function deriveContactAddrs(
let addrs = {}

for await (let c of appState.contacts) {
let og = Object.values(c[dir] || [])?.[0]
let og = Object.values(c[dir] || {})?.[0]
let xkey = og?.xpub || og?.xprv

if (xkey) {
Expand Down Expand Up @@ -1971,7 +1974,7 @@ export async function deriveContactAddrs(
return addrs
}

export async function getTxs(appState) {
export async function getTxs(appState, transactions = []) {
let contactAddrs = await getContactsFromAddrs(appState)
let contactOutAddrs = await deriveContactAddrs(appState)

Expand All @@ -1991,6 +1994,7 @@ export async function getTxs(appState) {

let txs = await getAddrsTransactions({
appState, addrs, contactAddrs,
txs: transactions,
})

// console.log('getTxs', {
Expand Down
11 changes: 9 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -808,11 +808,18 @@ async function main() {
</section>
`)

let txs = await getTxs(
appState,
Object.values(appState.transactions || {})
)

await transactionsList.render({
// transactions: appState.transactions,
userInfo,
contacts: appState.contacts,
transactions: Object.values(txs.byTx),
})

let txs = await getTxs(appState)
txs = await getTxs(appState)

console.log('main getTxs', txs)

Expand Down

0 comments on commit a2db906

Please sign in to comment.