Skip to content

Commit

Permalink
Fix autopolling, to append new transaction to the old transactions el…
Browse files Browse the repository at this point in the history
…se retain the current trsanactions
  • Loading branch information
ItsMurumba committed Sep 5, 2024
1 parent 7d11535 commit cbe2a7f
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,20 @@ const App: React.FC = () => {
fetchParams.filterPage = 0
}

const transactions = await getTransactions(fetchParams)
const newTransactions = await getTransactions(fetchParams)

const transactionsWithChannelDetails = await Promise.all(
transactions.map(async transaction => {
const newTransactionsWithChannelDetails = await Promise.all(
newTransactions.map(async transaction => {
const channelName = await fetchChannelDetails(transaction.channelID)
const clientName = await fetchClientDetails(transaction.clientID)
return {...transaction, channelName, clientName}
})
)

setTransactions(transactionsWithChannelDetails)
setTransactions(prevTransactions => [
...newTransactionsWithChannelDetails,
...prevTransactions
])
} catch (error) {
console.error('Error fetching logs:', error)
}
Expand Down

0 comments on commit cbe2a7f

Please sign in to comment.