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
fe030412
Unverified
Commit
fe030412
authored
Jun 22, 2020
by
Moody Salem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improvement(pair search modal): show exact symbol match pairs first, filter before sorting
parent
4d5a4335
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
7 deletions
+13
-7
PairSearchModal.tsx
src/components/SearchModal/PairSearchModal.tsx
+13
-7
No files found.
src/components/SearchModal/PairSearchModal.tsx
View file @
fe030412
...
@@ -54,17 +54,23 @@ function PairSearchModal({ history, isOpen, onDismiss }: PairSearchModalProps) {
...
@@ -54,17 +54,23 @@ function PairSearchModal({ history, isOpen, onDismiss }: PairSearchModalProps) {
setSearchQuery
(
checksummedInput
||
input
)
setSearchQuery
(
checksummedInput
||
input
)
}
}
const
filteredPairs
=
useMemo
(()
=>
{
return
filterPairs
(
allPairs
,
searchQuery
)
},
[
allPairs
,
searchQuery
])
const
sortedPairList
=
useMemo
(()
=>
{
const
sortedPairList
=
useMemo
(()
=>
{
return
allPairs
.
sort
((
a
,
b
):
number
=>
{
const
query
=
searchQuery
.
toLowerCase
()
const
queryMatches
=
(
pair
:
Pair
):
boolean
=>
pair
.
token0
.
symbol
.
toLowerCase
()
===
query
||
pair
.
token1
.
symbol
.
toLowerCase
()
===
query
return
filteredPairs
.
sort
((
a
,
b
):
number
=>
{
const
[
aMatches
,
bMatches
]
=
[
queryMatches
(
a
),
queryMatches
(
b
)]
if
(
aMatches
&&
!
bMatches
)
return
-
1
if
(
bMatches
&&
!
aMatches
)
return
1
const
balanceA
=
allPairBalances
[
a
.
liquidityToken
.
address
]
const
balanceA
=
allPairBalances
[
a
.
liquidityToken
.
address
]
const
balanceB
=
allPairBalances
[
b
.
liquidityToken
.
address
]
const
balanceB
=
allPairBalances
[
b
.
liquidityToken
.
address
]
return
pairComparator
(
a
,
b
,
balanceA
,
balanceB
)
return
pairComparator
(
a
,
b
,
balanceA
,
balanceB
)
})
})
},
[
allPairs
,
allPairBalances
])
},
[
searchQuery
,
filteredPairs
,
allPairBalances
])
const
filteredPairs
=
useMemo
(()
=>
{
return
filterPairs
(
sortedPairList
,
searchQuery
)
},
[
searchQuery
,
sortedPairList
])
const
selectPair
=
useCallback
(
const
selectPair
=
useCallback
(
(
pair
:
Pair
)
=>
{
(
pair
:
Pair
)
=>
{
...
@@ -110,7 +116,7 @@ function PairSearchModal({ history, isOpen, onDismiss }: PairSearchModalProps) {
...
@@ -110,7 +116,7 @@ function PairSearchModal({ history, isOpen, onDismiss }: PairSearchModalProps) {
</
PaddedColumn
>
</
PaddedColumn
>
<
div
style=
{
{
width
:
'
100%
'
,
height
:
'
1px
'
,
backgroundColor
:
theme
.
bg2
}
}
/>
<
div
style=
{
{
width
:
'
100%
'
,
height
:
'
1px
'
,
backgroundColor
:
theme
.
bg2
}
}
/>
<
PairList
<
PairList
pairs=
{
filteredPairs
}
pairs=
{
sortedPairList
}
focusTokenAddress=
{
focusedToken
?.
address
}
focusTokenAddress=
{
focusedToken
?.
address
}
onAddLiquidity=
{
selectPair
}
onAddLiquidity=
{
selectPair
}
onSelectPair=
{
selectPair
}
onSelectPair=
{
selectPair
}
...
...
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