Skip to content

Commit

Permalink
feat: Do not add the authenticator message if the 1CT swap tool is hi…
Browse files Browse the repository at this point in the history
…dden (#4019)
  • Loading branch information
JoseRFelix authored Dec 18, 2024
1 parent 5105742 commit 523e176
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/web/modals/review-order.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 523e176

Please sign in to comment.