Skip to content

Commit

Permalink
fix: avoid animations when rendering a historic receipt
Browse files Browse the repository at this point in the history
  • Loading branch information
agualis committed Sep 25, 2024
1 parent 4694ffe commit c54c22d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@ export function AddLiquidityModal({
}: Props & Omit<ModalProps, 'children'>) {
const { isDesktop } = useBreakpoints()
const initialFocusRef = useRef(null)
const { transactionSteps, addLiquidityTxHash, hasQuoteContext, setInitialHumanAmountsIn } =
useAddLiquidity()
const {
transactionSteps,
addLiquidityTxHash,
hasQuoteContext,
urlTxHash,
setInitialHumanAmountsIn,
} = useAddLiquidity()
const { pool, chain } = usePool()
const { redirectToPoolPage } = usePoolRedirect(pool)
const { userAddress } = useUserAccount()
Expand Down Expand Up @@ -101,6 +106,7 @@ export function AddLiquidityModal({
currentStep={transactionSteps.currentStep}
returnLabel="Return to pool"
returnAction={redirectToPoolPage}
urlTxHash={urlTxHash}
/>
</ModalContent>
</Modal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ export function _useRemoveLiquidity(urlTxHash?: Hash) {
previewModalDisclosure,
handler,
wethIsEth,
urlTxHash,
removeLiquidityTxHash,
hasQuoteContext,
amountsOut,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export function RemoveLiquidityModal({
}: Props & Omit<ModalProps, 'children'>) {
const { isDesktop } = useBreakpoints()
const initialFocusRef = useRef(null)
const { transactionSteps, removeLiquidityTxHash, hasQuoteContext } = useRemoveLiquidity()
const { transactionSteps, removeLiquidityTxHash, urlTxHash, hasQuoteContext } =
useRemoveLiquidity()
const { pool, chain } = usePool()
const { redirectToPoolPage } = usePoolRedirect(pool)
const { userAddress } = useUserAccount()
Expand Down Expand Up @@ -99,6 +100,7 @@ export function RemoveLiquidityModal({
currentStep={transactionSteps.currentStep}
returnLabel="Return to pool"
returnAction={redirectToPoolPage}
urlTxHash={urlTxHash}
/>
</ModalContent>
</Modal>
Expand Down
12 changes: 10 additions & 2 deletions lib/modules/swap/modal/SwapModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,15 @@ export function SwapPreviewModal({
const { userAddress } = useUserAccount()
const { stopTokenPricePolling } = useTokens()

const { transactionSteps, swapAction, isWrap, selectedChain, swapTxHash, hasQuoteContext } =
useSwap()
const {
transactionSteps,
swapAction,
isWrap,
selectedChain,
swapTxHash,
urlTxHash,
hasQuoteContext,
} = useSwap()

const swapReceipt = useSwapReceipt({
txHash: swapTxHash,
Expand Down Expand Up @@ -97,6 +104,7 @@ export function SwapPreviewModal({
currentStep={transactionSteps.currentStep}
returnLabel="Swap again"
returnAction={onClose}
urlTxHash={urlTxHash}
/>
</ModalContent>
</Modal>
Expand Down
17 changes: 16 additions & 1 deletion lib/shared/components/modals/ActionModalFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,24 @@ type Props = {
currentStep: TransactionStep
returnLabel: string
returnAction: () => void
urlTxHash?: string
}

export function ActionModalFooter({ isSuccess, currentStep, returnLabel, returnAction }: Props) {
export function ActionModalFooter({
isSuccess,
currentStep,
returnLabel,
returnAction,
urlTxHash,
}: Props) {
// Avoid animations when displaying a historic receipt
if (urlTxHash) {
return (
<ModalFooter>
<SuccessActions returnLabel={returnLabel} returnAction={returnAction} />
</ModalFooter>
)
}
return (
<ModalFooter>
<AnimatePresence mode="wait" initial={false}>
Expand Down

0 comments on commit c54c22d

Please sign in to comment.