diff --git a/CHANGELOG.md b/CHANGELOG.md index 45c6165a821..b29356bc48d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` diff --git a/src/hooks/useTransactionList.ts b/src/hooks/useTransactionList.ts index 1d093b1cffa..edd82b54a19 100644 --- a/src/hooks/useTransactionList.ts +++ b/src/hooks/useTransactionList.ts @@ -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>({ @@ -105,7 +112,7 @@ export function useTransactionList(wallet: EdgeCurrencyWallet, tokenId: EdgeToke batchSize: 30, firstBatchSize: 10, searchString, - spamThreshold, + spamThreshold: spamThresholdRef.current, tokenId }) @@ -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,