Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
a73f59b4
Unverified
Commit
a73f59b4
authored
Mar 17, 2022
by
Zach Pomerantz
Committed by
GitHub
Mar 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: only debounce input amounts (#3540)
parent
7a75626c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
useClientSideSmartOrderRouterTrade.ts
src/lib/hooks/routing/useClientSideSmartOrderRouterTrade.ts
+4
-4
No files found.
src/lib/hooks/routing/useClientSideSmartOrderRouterTrade.ts
View file @
a73f59b4
...
@@ -42,10 +42,10 @@ export default function useClientSideSmartOrderRouterTrade<TTradeType extends Tr
...
@@ -42,10 +42,10 @@ export default function useClientSideSmartOrderRouterTrade<TTradeType extends Tr
trade
:
InterfaceTrade
<
Currency
,
Currency
,
TTradeType
>
|
undefined
trade
:
InterfaceTrade
<
Currency
,
Currency
,
TTradeType
>
|
undefined
}
{
}
{
// Debounce is used to prevent excessive requests to SOR, as it is data intensive.
// Debounce is used to prevent excessive requests to SOR, as it is data intensive.
//
This helps provide a "syncing" state the UI can reference for loading animations
.
//
Fast user actions (ie updating the input) should be debounced, but currency changes should not
.
const
inputs
=
useMemo
(()
=>
[
tradeType
,
amountSpecified
,
otherCurrency
],
[
tradeType
,
amountSpecified
,
otherCurrency
]
)
const
debouncedAmountSpecified
=
useDebounce
(
amountSpecified
,
200
)
const
debouncedInputs
=
useDebounce
(
inputs
,
200
)
const
isDebouncing
=
const
isDebouncing
=
inputs
!==
debouncedInputs
amountSpecified
!==
debouncedAmountSpecified
&&
amountSpecified
?.
currency
===
debouncedAmountSpecified
?.
currency
const
chainId
=
amountSpecified
?.
currency
.
chainId
const
chainId
=
amountSpecified
?.
currency
.
chainId
const
{
library
}
=
useActiveWeb3React
()
const
{
library
}
=
useActiveWeb3React
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment