From 523e176f8f07d23cdfecff8dab58f5f5354b4b9d Mon Sep 17 00:00:00 2001 From: Jose Felix Date: Wed, 18 Dec 2024 11:23:09 -0400 Subject: [PATCH] feat: Do not add the authenticator message if the 1CT swap tool is hidden (#4019) --- .../use-one-click-trading-swap-review.ts | 20 +++++++++---------- packages/web/modals/review-order.tsx | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/web/hooks/one-click-trading/use-one-click-trading-swap-review.ts b/packages/web/hooks/one-click-trading/use-one-click-trading-swap-review.ts index 9a525575ed..8db595e6a4 100644 --- a/packages/web/hooks/one-click-trading/use-one-click-trading-swap-review.ts +++ b/packages/web/hooks/one-click-trading/use-one-click-trading-swap-review.ts @@ -40,9 +40,9 @@ const use1CTSwapReviewStore = create<{ })); export function useOneClickTradingSwapReview({ - isModalOpen, + enabled, }: { - isModalOpen: boolean; + enabled: boolean; }) { const [previousIsOneClickEnabled, setPreviousIsOneClickEnabled] = useLocalStorage("previous-one-click-enabled", true); @@ -76,36 +76,36 @@ export function useOneClickTradingSwapReview({ const isLoading = isLoadingInfo; useEffect(() => { - if (isModalOpen) { + if (enabled) { use1CTSwapReviewStore .getState() .setTransaction1CTParams(transactionParams); } - }, [transactionParams, isModalOpen]); + }, [transactionParams, enabled]); useEffect(() => { - if (isModalOpen) { + if (enabled) { use1CTSwapReviewStore .getState() .setSpendLimitTokenDecimals(spendLimitTokenDecimals); } - }, [isModalOpen, spendLimitTokenDecimals]); + }, [enabled, spendLimitTokenDecimals]); useEffect(() => { - if (isModalOpen) { + if (enabled) { use1CTSwapReviewStore.getState().setChanges(changes); } - }, [isModalOpen, changes]); + }, [enabled, changes]); useEffect(() => { - if (!isModalOpen) { + if (!enabled) { const state = use1CTSwapReviewStore.getState(); resetParams(); state.setTransaction1CTParams(undefined); state.setSpendLimitTokenDecimals(undefined); state.setChanges(undefined); } - }, [isModalOpen, resetParams]); + }, [enabled, resetParams]); return { isEnabled, diff --git a/packages/web/modals/review-order.tsx b/packages/web/modals/review-order.tsx index d484e347a6..9cc211564a 100644 --- a/packages/web/modals/review-order.tsx +++ b/packages/web/modals/review-order.tsx @@ -131,7 +131,7 @@ export function ReviewOrder({ setTransactionParams: setTransaction1CTParams, resetParams: reset1CTParams, setPreviousIsOneClickEnabled, - } = useOneClickTradingSwapReview({ isModalOpen: isOpen }); + } = useOneClickTradingSwapReview({ enabled: isOpen && show1CT }); const wouldExceedSpendLimit = useMemo(() => { if (!is1CTEnabled) return false;