Skip to content

Commit

Permalink
[NO CHANGELOGS] [Add Funds Widget] Fix/add funds debounce (#2305)
Browse files Browse the repository at this point in the history
  • Loading branch information
mimi-imtbl authored Oct 15, 2024
1 parent c9c5d42 commit 389df16
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export function AddFunds({
[tokens, inputValue, selectedToken],
);

const setSelectedAmount = debounce((value: string) => {
const setSelectedAmount = useMemo(() => debounce((value: string) => {
track({
userJourney: UserJourney.ADD_FUNDS,
screen: 'InputScreen',
Expand All @@ -147,7 +147,7 @@ export function AddFunds({
selectedAmount: value,
},
});
}, 2500);
}, 2500), []);

const setSelectedToken = (token: TokenInfo | undefined) => {
track({
Expand Down Expand Up @@ -477,10 +477,16 @@ export function AddFunds({
const shouldShowBackButton = showBackButton ?? !!onBackButtonClick;
const routeInputsReady = !!selectedToken
&& !!fromAddress
&& validateToAmount(selectedAmount).isValid;
&& validateToAmount(selectedAmount).isValid
&& validateToAmount(inputValue).isValid;

const loading = (routeInputsReady || fetchingRoutes)
&& !(selectedRouteData || insufficientBalance);
const readyToReview = routeInputsReady && !!toAddress && !!selectedRouteData && !loading;

const readyToReview = routeInputsReady
&& !!toAddress
&& !!selectedRouteData
&& !loading;

const handleWalletConnected = (
providerType: 'from' | 'to',
Expand Down

0 comments on commit 389df16

Please sign in to comment.