From 82c214d2b46b76b8905809763a4aed9fb942f921 Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 6 Aug 2024 14:04:04 +0800 Subject: [PATCH] problem: wrong profile sometimes displayed on `/buymerits` --- src/routes/buymerits/+page.svelte | 44 ++++++++++++++++++------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/routes/buymerits/+page.svelte b/src/routes/buymerits/+page.svelte index 5fbaf17..1d9b6f4 100644 --- a/src/routes/buymerits/+page.svelte +++ b/src/routes/buymerits/+page.svelte @@ -51,20 +51,22 @@ _transactions.set(amr.RxAddress, new txs(amr.RxAddress)); } let existing = _transactions.get(amr.RxAddress)!; - if ( - Math.floor(new Date().getTime() / 1000) > existing.LastAttempt + 10000 - ) { + if (Math.floor(new Date().getTime() / 1000) > existing.LastAttempt + 10000) { existing.LastAttempt = Math.floor(new Date().getTime() / 1000); - getIncomingTransactions(amr.RxAddress).then((result) => { - if (result) { - existing.LastUpdate = Math.floor(new Date().getTime() / 1000); - } - if (result.length > 0) { - existing.Data = result; - _transactions.set(amr.RxAddress, existing); - _transactions = _transactions; - } - }).catch(c=>{console.log(c)}); + getIncomingTransactions(amr.RxAddress) + .then((result) => { + if (result) { + existing.LastUpdate = Math.floor(new Date().getTime() / 1000); + } + if (result.length > 0) { + existing.Data = result; + _transactions.set(amr.RxAddress, existing); + _transactions = _transactions; + } + }) + .catch((c) => { + console.log(c); + }); } } } @@ -82,17 +84,21 @@ amrAuction.Status(r, $bitcoinTip.height, $transactions.get(amrAuction.RxAddress)) == 'SOLD & PENDING RATIFICATION' ) { - let txs = $transactions.get(amrAuction.RxAddress) + let txs = $transactions.get(amrAuction.RxAddress); if (txs) { for (let [address, txo] of txs.From()) { for (let [_, ba] of r.BitcoinAssociations()) { if (ba.Address == txo.From) { - return {auction:amrAuction, buyer: ba.Pubkey, txid: txo.ID, sats: txo.Amount} + return { + auction: amrAuction, + buyer: ba.Pubkey, + txid: txo.ID, + sats: txo.Amount + }; } } } } - } } } @@ -127,7 +133,7 @@ {#if $noAssociatedBitcoinAddress}{/if} {#if $currentUser} - {#each $pendingSales as [rocket, amr]} + {#each $pendingSales as [rocket, amr] (rocket.Event.id)} {#if amr.length > 0} @@ -143,13 +149,13 @@ - {#each amr as p} + {#each amr as p (p.AMRIDs)}