Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
brtkx committed Dec 18, 2024
1 parent 63fae30 commit 2740d95
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions packages/arb-token-bridge-ui/src/hooks/useTransactionHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -831,10 +831,22 @@ const useMappedSenderTransactionHistory = ({

const updatePendingTransaction = useCallback(
async (tx: MergedTransaction) => {
if (!senderTxPages) {
return
}

const foundInSwrCache = senderTxPages
.flat()
.find(t => tx.txId === t.txId && tx.childChainId === t.childChainId)

if (!foundInSwrCache) {
return
}

const updatedPendingTransaction = await getUpdatedPendingTransaction(tx)
updateTransactionInSwrCache(updatedPendingTransaction)
},
[updateTransactionInSwrCache]
[senderTxPages, updateTransactionInSwrCache]
)

// based on an example from SWR
Expand Down Expand Up @@ -1009,10 +1021,22 @@ const useMappedReceiverTransactionHistory = ({

const updatePendingTransaction = useCallback(
async (tx: MergedTransaction) => {
if (!receiverTransactions) {
return
}

const foundInSwrCache = receiverTransactions
.flat()
.find(t => tx.txId === t.txId && tx.childChainId === t.childChainId)

if (!foundInSwrCache) {
return
}

const updatedPendingTransaction = await getUpdatedPendingTransaction(tx)
updateTransactionInSwrCache(updatedPendingTransaction)
},
[updateTransactionInSwrCache]
[receiverTransactions, updateTransactionInSwrCache]
)

useEffect(() => {
Expand Down Expand Up @@ -1079,14 +1103,11 @@ export const useTransactionHistory = (
const { cctpTransactions, cctpLoading } = useCctpTransactions({ address })

const updatePendingTransaction = useCallback(
(tx: MergedTransaction) => {
if (address?.toLowerCase() !== tx.sender?.toLowerCase()) {
return updatePendingReceiverTransaction(tx)
}

return updatePendingSenderTransaction(tx)
async (tx: MergedTransaction) => {
await updatePendingSenderTransaction(tx)
await updatePendingReceiverTransaction(tx)
},
[address, updatePendingReceiverTransaction, updatePendingSenderTransaction]
[updatePendingReceiverTransaction, updatePendingSenderTransaction]
)

return {
Expand Down

0 comments on commit 2740d95

Please sign in to comment.