Skip to content

Commit

Permalink
fix(bridge): multiple message processed toasts (#8186)
Browse files Browse the repository at this point in the history
  • Loading branch information
shadab-taiko committed Jan 5, 2023
1 parent 1ad4433 commit a091bc0
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions packages/bridge-ui/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,29 @@
});
});
const transactionToIntervalMap = new Map();
transactions.subscribe((store) => {
if (store) {
store.forEach(async (tx) => {
if (tx.interval) clearInterval(tx.interval);
const txInterval = transactionToIntervalMap.get(tx.ethersTx.hash);
if (txInterval) {
clearInterval(txInterval);
transactionToIntervalMap.delete(tx.ethersTx.hash);
}
if (tx.status === MessageStatus.New) {
const provider = providerMap.get(tx.toChainId);
const interval = setInterval(async () => {
tx.interval = interval;
const txInterval = transactionToIntervalMap.get(tx.ethersTx.hash);
if (txInterval !== interval) {
clearInterval(txInterval);
transactionToIntervalMap.delete(tx.ethersTx.hash);
}
transactionToIntervalMap.set(tx.ethersTx.hash, interval);
if (!tx.signal) return;
const contract = new ethers.Contract(
Expand All @@ -180,7 +193,9 @@
if (messageStatus === MessageStatus.Done) {
successToast("Bridge message processed successfully");
clearInterval(tx.interval);
const txOngoingInterval = transactionToIntervalMap.get(tx.ethersTx.hash);
clearInterval(txOngoingInterval);
transactionToIntervalMap.delete(tx.ethersTx.hash);
}
}, 20 * 1000);
}
Expand Down

0 comments on commit a091bc0

Please sign in to comment.