Skip to content

Commit

Permalink
feat: open 'showMore' after quote refresh for non-auto slippage
Browse files Browse the repository at this point in the history
  • Loading branch information
dmy147 committed Dec 19, 2024
1 parent 0bae1a2 commit 6a60550
Showing 1 changed file with 36 additions and 5 deletions.
41 changes: 36 additions & 5 deletions src/ui/views/Swap/Component/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { useQuoteVisible, useSetQuoteVisible, useSetRefreshId } from '../hooks';
import { DEX_ENUM, DEX_SPENDER_WHITELIST } from '@rabby-wallet/rabby-swap';
import { useDispatch } from 'react-redux';
import { useRbiSource } from '@/ui/utils/ga-event';
import { useCss } from 'react-use';
import { useCss, useDebounce } from 'react-use';
import {
DEX_WITH_WRAP,
KEYRING_CLASS,
Expand Down Expand Up @@ -393,11 +393,42 @@ export const Main = () => {
]
);

const noQuote = useDebounceValue(noQuoteOrigin, 16);
const noQuote = useDebounceValue(noQuoteOrigin, 10);

if (noQuote && !showMoreOpen) {
setShowMoreOpen(true);
}
useEffect(() => {
if (noQuote) {
setShowMoreOpen(true);
}
}, [noQuote]);

useDebounce(
() => {
if (
Number(inputAmount) > 0 &&
!inSufficient &&
amountAvailable &&
!quoteLoading &&
!!payToken &&
!!receiveToken &&
!autoSlippage &&
activeProvider
) {
setShowMoreOpen(true);
}
},
10,
[
inputAmount,
inSufficient,
amountAvailable,
payToken,
receiveToken,
activeProvider,
autoSlippage,
activeProvider,
quoteLoading,
]
);

return (
<div
Expand Down

0 comments on commit 6a60550

Please sign in to comment.