Skip to content

Commit

Permalink
fix(tx-list): updating with new txs (#3464)
Browse files Browse the repository at this point in the history
  • Loading branch information
banklesss authored Jul 29, 2024
1 parent 6c53986 commit 2c47b63
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,20 @@ export const TxList = (props: Props) => {
const {wallet} = useSelectedWallet()

const filter = useTxFilter()
const transactions = useTransactionInfos({wallet})
const filteredTransactions = React.useMemo(() => filterTransactions(transactions, filter), [transactions, filter])
const transactionInfos = useTransactionInfos({wallet})
const filteredTransactions = React.useMemo(
() => filterTransactions(transactionInfos, filter),
[transactionInfos, filter],
)

const [loadedTxs, setLoadedTxs] = React.useState(filteredTransactions.slice(0, batchSize))
const [currentIndex, setCurrentIndex] = React.useState(batchSize)

React.useEffect(() => {
setLoadedTxs(filteredTransactions.slice(0, batchSize))
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [transactionInfos]) // must be transactionInfos

const handleOnEndReached = React.useCallback(() => {
if (currentIndex >= filteredTransactions.length) return
const nextBatch = filteredTransactions.slice(currentIndex, currentIndex + batchSize)
Expand Down
2 changes: 1 addition & 1 deletion apps/wallet-mobile/src/yoroi-wallets/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ export const useTransactionInfos = ({wallet}: {wallet: YoroiWallet}) => {
const unsubscribe = wallet.subscribe((event) => {
if (event.type !== 'transactions') return

setTransactionInfos(wallet.transactions)
setTransactionInfos(() => wallet.transactions)
})
return () => unsubscribe?.()
}, [wallet])
Expand Down

0 comments on commit 2c47b63

Please sign in to comment.