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
d1897448
Unverified
Commit
d1897448
authored
Nov 01, 2021
by
Moody Salem
Committed by
GitHub
Nov 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: memoize the list stuff so the tokens are consistently clickable (#2724)
parent
6a90bf3b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
8 deletions
+17
-8
CurrencySearchModal.tsx
src/components/SearchModal/CurrencySearchModal.tsx
+10
-5
hooks.ts
src/state/lists/hooks.ts
+7
-3
No files found.
src/components/SearchModal/CurrencySearchModal.tsx
View file @
d1897448
...
@@ -66,6 +66,13 @@ export default function CurrencySearchModal({
...
@@ -66,6 +66,13 @@ export default function CurrencySearchModal({
const
[
importList
,
setImportList
]
=
useState
<
TokenList
|
undefined
>
()
const
[
importList
,
setImportList
]
=
useState
<
TokenList
|
undefined
>
()
const
[
listURL
,
setListUrl
]
=
useState
<
string
|
undefined
>
()
const
[
listURL
,
setListUrl
]
=
useState
<
string
|
undefined
>
()
const
showImportView
=
useCallback
(()
=>
setModalView
(
CurrencyModalView
.
importToken
),
[
setModalView
])
const
showManageView
=
useCallback
(()
=>
setModalView
(
CurrencyModalView
.
manage
),
[
setModalView
])
const
handleBackImport
=
useCallback
(
()
=>
setModalView
(
prevView
&&
prevView
!==
CurrencyModalView
.
importToken
?
prevView
:
CurrencyModalView
.
search
),
[
setModalView
,
prevView
]
)
// change min height if not searching
// change min height if not searching
const
minHeight
=
modalView
===
CurrencyModalView
.
importToken
||
modalView
===
CurrencyModalView
.
importList
?
40
:
80
const
minHeight
=
modalView
===
CurrencyModalView
.
importToken
||
modalView
===
CurrencyModalView
.
importList
?
40
:
80
let
content
=
null
let
content
=
null
...
@@ -81,9 +88,9 @@ export default function CurrencySearchModal({
...
@@ -81,9 +88,9 @@ export default function CurrencySearchModal({
showCommonBases=
{
showCommonBases
}
showCommonBases=
{
showCommonBases
}
showCurrencyAmount=
{
showCurrencyAmount
}
showCurrencyAmount=
{
showCurrencyAmount
}
disableNonToken=
{
disableNonToken
}
disableNonToken=
{
disableNonToken
}
showImportView=
{
()
=>
setModalView
(
CurrencyModalView
.
importToken
)
}
showImportView=
{
showImportView
}
setImportToken=
{
setImportToken
}
setImportToken=
{
setImportToken
}
showManageView=
{
()
=>
setModalView
(
CurrencyModalView
.
manage
)
}
showManageView=
{
showManageView
}
/>
/>
)
)
break
break
...
@@ -94,9 +101,7 @@ export default function CurrencySearchModal({
...
@@ -94,9 +101,7 @@ export default function CurrencySearchModal({
tokens=
{
[
importToken
]
}
tokens=
{
[
importToken
]
}
onDismiss=
{
onDismiss
}
onDismiss=
{
onDismiss
}
list=
{
importToken
instanceof
WrappedTokenInfo
?
importToken
.
list
:
undefined
}
list=
{
importToken
instanceof
WrappedTokenInfo
?
importToken
.
list
:
undefined
}
onBack=
{
()
=>
onBack=
{
handleBackImport
}
setModalView
(
prevView
&&
prevView
!==
CurrencyModalView
.
importToken
?
prevView
:
CurrencyModalView
.
search
)
}
handleCurrencySelect=
{
handleCurrencySelect
}
handleCurrencySelect=
{
handleCurrencySelect
}
/>
/>
)
)
...
...
src/state/lists/hooks.ts
View file @
d1897448
...
@@ -99,20 +99,24 @@ function useCombinedTokenMapFromUrls(urls: string[] | undefined): TokenAddressMa
...
@@ -99,20 +99,24 @@ function useCombinedTokenMapFromUrls(urls: string[] | undefined): TokenAddressMa
// filter out unsupported lists
// filter out unsupported lists
export
function
useActiveListUrls
():
string
[]
|
undefined
{
export
function
useActiveListUrls
():
string
[]
|
undefined
{
return
useAppSelector
((
state
)
=>
state
.
lists
.
activeListUrls
)?.
filter
((
url
)
=>
!
UNSUPPORTED_LIST_URLS
.
includes
(
url
))
const
activeListUrls
=
useAppSelector
((
state
)
=>
state
.
lists
.
activeListUrls
)
return
useMemo
(()
=>
activeListUrls
?.
filter
((
url
)
=>
!
UNSUPPORTED_LIST_URLS
.
includes
(
url
)),
[
activeListUrls
])
}
}
export
function
useInactiveListUrls
():
string
[]
{
export
function
useInactiveListUrls
():
string
[]
{
const
lists
=
useAllLists
()
const
lists
=
useAllLists
()
const
allActiveListUrls
=
useActiveListUrls
()
const
allActiveListUrls
=
useActiveListUrls
()
return
Object
.
keys
(
lists
).
filter
((
url
)
=>
!
allActiveListUrls
?.
includes
(
url
)
&&
!
UNSUPPORTED_LIST_URLS
.
includes
(
url
))
return
useMemo
(
()
=>
Object
.
keys
(
lists
).
filter
((
url
)
=>
!
allActiveListUrls
?.
includes
(
url
)
&&
!
UNSUPPORTED_LIST_URLS
.
includes
(
url
)),
[
lists
,
allActiveListUrls
]
)
}
}
// get all the tokens from active lists, combine with local default tokens
// get all the tokens from active lists, combine with local default tokens
export
function
useCombinedActiveList
():
TokenAddressMap
{
export
function
useCombinedActiveList
():
TokenAddressMap
{
const
activeListUrls
=
useActiveListUrls
()
const
activeListUrls
=
useActiveListUrls
()
const
activeTokens
=
useCombinedTokenMapFromUrls
(
activeListUrls
)
const
activeTokens
=
useCombinedTokenMapFromUrls
(
activeListUrls
)
return
combineMaps
(
activeTokens
,
TRANSFORMED_DEFAULT_TOKEN_LIST
)
return
useMemo
(()
=>
combineMaps
(
activeTokens
,
TRANSFORMED_DEFAULT_TOKEN_LIST
),
[
activeTokens
]
)
}
}
// list of tokens not supported on interface for various reasons, used to show warnings and prevent swaps and adds
// list of tokens not supported on interface for various reasons, used to show warnings and prevent swaps and adds
...
...
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