Skip to content

Commit

Permalink
Merge pull request #5299 from EdgeApp/matthew/tx-list-refresh
Browse files Browse the repository at this point in the history
Prevent exchange rate fluctuations from restarting transaction list stream
  • Loading branch information
peachbits authored Oct 11, 2024
2 parents d50694d + e932bc1 commit 7a8d752
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- added: Include wallet creation date in wallet data in log output
- changed: Enable Ethereum staking
- changed: Prevent exchange rate fluctuations from restarting transaction list stream
- changed: Call `saveTx` after signing or broadcasting transactions from WalletConnect
- changed: Navigate to wallet list after restoring wallets
- fixed: Use account default fiat for transaction fee display in `SweepPrivateKeyCalculateFeeScene`
Expand Down
12 changes: 10 additions & 2 deletions src/hooks/useTransactionList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ export function useTransactionList(wallet: EdgeCurrencyWallet, tokenId: EdgeToke

const requestMore = React.useRef(() => {})

// Ignore changes to the spamThreshold unless it's changing to or from 0
// This prevents starting the stream over when the exchange rate changes
const spamThresholdRef = React.useRef(spamThreshold)
if (spamThreshold !== spamThresholdRef.current && (spamThreshold === '0' || spamThresholdRef.current === '0')) {
spamThresholdRef.current = spamThreshold
}

// The effect maintains internal mutable state,
// and then calls `setOutput` to expose it atomically.
const [output, setOutput] = React.useState<Omit<Output, 'requestMore'>>({
Expand Down Expand Up @@ -105,7 +112,7 @@ export function useTransactionList(wallet: EdgeCurrencyWallet, tokenId: EdgeToke
batchSize: 30,
firstBatchSize: 10,
searchString,
spamThreshold,
spamThreshold: spamThresholdRef.current,
tokenId
})

Expand Down Expand Up @@ -153,7 +160,8 @@ export function useTransactionList(wallet: EdgeCurrencyWallet, tokenId: EdgeToke
cleanupChanged()
cleanupStream()
}
}, [searchString, spamThreshold, tokenId, wallet])
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [searchString, spamThresholdRef.current, tokenId, wallet])

return {
...output,
Expand Down

0 comments on commit 7a8d752

Please sign in to comment.