@@ -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