Skip to content

Commit

Permalink
fix: trade countdown fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gomesalexandre committed Sep 25, 2024
1 parent 2760692 commit ee83624
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ export const Hop = ({
)
)
case TransactionExecutionState.Pending:
// The hop may be pending, but it doesn't mean that it has been signed and broadcasted
if (!swap.sellTxHash) {
return (
tradeQuoteStep.estimatedExecutionTimeMs !== undefined && (
<RawText fontWeight='bold'>
{prettyMilliseconds(tradeQuoteStep.estimatedExecutionTimeMs)}
</RawText>
)
)
}
return (
tradeQuoteStep.estimatedExecutionTimeMs !== undefined && (
<TimeRemaining initialTimeMs={tradeQuoteStep.estimatedExecutionTimeMs} />
Expand All @@ -139,7 +149,7 @@ export const Hop = ({
default:
return null
}
}, [swap.state, tradeQuoteStep.estimatedExecutionTimeMs, onToggleIsOpen, isOpen])
}, [swap.state, swap.sellTxHash, tradeQuoteStep.estimatedExecutionTimeMs, onToggleIsOpen, isOpen])

const activeStep = useMemo(() => {
switch (hopExecutionState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ export const useCountdown = (
})
}, [onCompleted])

useEffect(() => {
return () => {
if (id.current) clearInterval(id.current)
}
}, [handleDecrement])

const start = useCallback((): void => {
if (id.current) return
id.current = setInterval(handleDecrement, 1000)
Expand Down

0 comments on commit ee83624

Please sign in to comment.