Skip to content

Commit 4c12abe

Browse files
authored
Merge pull request #5449 from EdgeApp/sam/tx-metadata-shmetadata
Fix transaction metadata loading issues
2 parents 179ce65 + 3472d7c commit 4c12abe

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- changed: Replace Thorchain Savers quoting with an information modal about the shutdown.
1515
- fixed: Show correct staked balance for deprecated Velodrome pools
1616
- fixed: Crash when retrieving `exchangeRates` in some situations when no internet is available
17+
- fixed: Transaction metadata loading bugs.
1718

1819
## 4.21.1 (2025-01-28)
1920

src/hooks/useTransactionList.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ export function useTransactionList(wallet: EdgeCurrencyWallet, tokenId: EdgeToke
5050
// Reset our mutable state to an empty list:
5151
let atEnd = false
5252
const changedTxs = new Map<string, EdgeTransaction>()
53-
const txs: EdgeTransaction[] = []
53+
const streamedTxs: EdgeTransaction[] = []
5454

5555
// Sends the mutable state to React,
5656
// merging the two transaction lists together:
5757
function requestRender() {
58-
const mergedTxs = txs.filter(tx => !changedTxs.has(tx.txid))
58+
const mergedTxs = streamedTxs.filter(tx => !changedTxs.has(tx.txid))
5959
mergedTxs.push(...changedTxs.values())
6060
mergedTxs.sort((a, b) => b.date - a.date)
6161

@@ -84,8 +84,10 @@ export function useTransactionList(wallet: EdgeCurrencyWallet, tokenId: EdgeToke
8484
// but just overlay the new transactions over the old ones:
8585
const cleanupChanged = wallet.on('transactionsChanged', txs => {
8686
let relevant = false
87+
const existingTxidsSet = new Set<string>()
88+
streamedTxs.forEach(tx => existingTxidsSet.add(tx.txid))
8789
for (const tx of txs) {
88-
if (tx.tokenId === tokenId) {
90+
if (tx.tokenId === tokenId && existingTxidsSet.has(tx.txid)) {
8991
relevant = true
9092
changedTxs.set(tx.txid, tx)
9193
}
@@ -131,14 +133,14 @@ export function useTransactionList(wallet: EdgeCurrencyWallet, tokenId: EdgeToke
131133
if (closed) return
132134
if (result.done) {
133135
atEnd = true
134-
txs.splice(offset, Infinity) // Trim stragglers
136+
streamedTxs.splice(offset, Infinity) // Trim stragglers
135137
requestRender()
136138
} else {
137139
const { value } = result
138-
txs.splice(offset, value.length, ...value)
140+
streamedTxs.splice(offset, value.length, ...value)
139141
offset += value.length
140142
requestRender()
141-
if (offset < txs.length) requestMore.current()
143+
if (offset < streamedTxs.length) requestMore.current()
142144
}
143145
},
144146
error => {

0 commit comments

Comments
 (0)