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
db5c6f82
Unverified
Commit
db5c6f82
authored
Sep 15, 2022
by
Jack Short
Committed by
GitHub
Sep 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: search rerender (#4640)
parent
f161f961
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
9 deletions
+8
-9
SearchBar.tsx
src/components/NavBar/SearchBar.tsx
+8
-9
No files found.
src/components/NavBar/SearchBar.tsx
View file @
db5c6f82
...
...
@@ -96,9 +96,8 @@ interface SearchBarDropdownProps {
export
const
SearchBarDropdown
=
({
toggleOpen
,
tokens
,
collections
,
hasInput
,
isLoading
}:
SearchBarDropdownProps
)
=>
{
const
[
hoveredIndex
,
setHoveredIndex
]
=
useState
<
number
|
undefined
>
(
0
)
const
searchHistory
=
useSearchHistory
(
(
state
:
{
history
:
(
FungibleToken
|
GenieCollection
)[]
})
=>
state
.
history
).
slice
(
0
,
2
)
const
searchHistory
=
useSearchHistory
((
state
:
{
history
:
(
FungibleToken
|
GenieCollection
)[]
})
=>
state
.
history
)
const
shortenedHistory
=
useMemo
(()
=>
searchHistory
.
slice
(
0
,
2
),
[
searchHistory
])
const
{
pathname
}
=
useLocation
()
const
isNFTPage
=
pathname
.
includes
(
'
/nfts
'
)
const
isTokenPage
=
pathname
.
includes
(
'
/tokens
'
)
...
...
@@ -182,7 +181,7 @@ export const SearchBarDropdown = ({ toggleOpen, tokens, collections, hasInput, i
const
totalSuggestions
=
hasInput
?
tokens
.
length
+
collections
.
length
:
Math
.
min
(
s
earch
History
.
length
,
2
)
+
:
Math
.
min
(
s
hortened
History
.
length
,
2
)
+
(
isNFTPage
||
!
isTokenPage
?
trendingCollections
?.
length
??
0
:
0
)
+
(
isTokenPage
||
!
isNFTPage
?
trendingTokens
?.
length
??
0
:
0
)
...
...
@@ -234,13 +233,13 @@ export const SearchBarDropdown = ({ toggleOpen, tokens, collections, hasInput, i
)
:
(
// Recent Searches, Trending Tokens, Trending Collections
<
Column
gap=
"20"
>
{
s
earch
History
.
length
>
0
&&
(
{
s
hortened
History
.
length
>
0
&&
(
<
SearchBarDropdownSection
hoveredIndex=
{
hoveredIndex
}
startingIndex=
{
0
}
setHoveredIndex=
{
setHoveredIndex
}
toggleOpen=
{
toggleOpen
}
suggestions=
{
s
earch
History
}
suggestions=
{
s
hortened
History
}
header=
{
<
Trans
>
Recent searches
</
Trans
>
}
headerIcon=
{
<
ClockIcon
/>
}
/>
...
...
@@ -248,7 +247,7 @@ export const SearchBarDropdown = ({ toggleOpen, tokens, collections, hasInput, i
{
!
isNFTPage
&&
(
<
SearchBarDropdownSection
hoveredIndex=
{
hoveredIndex
}
startingIndex=
{
s
earch
History
.
length
}
startingIndex=
{
s
hortened
History
.
length
}
setHoveredIndex=
{
setHoveredIndex
}
toggleOpen=
{
toggleOpen
}
suggestions=
{
trendingTokens
}
...
...
@@ -260,7 +259,7 @@ export const SearchBarDropdown = ({ toggleOpen, tokens, collections, hasInput, i
{
!
isTokenPage
&&
phase1Flag
===
NftVariant
.
Enabled
&&
(
<
SearchBarDropdownSection
hoveredIndex=
{
hoveredIndex
}
startingIndex=
{
s
earch
History
.
length
+
(
isNFTPage
?
0
:
trendingTokens
?.
length
??
0
)
}
startingIndex=
{
s
hortened
History
.
length
+
(
isNFTPage
?
0
:
trendingTokens
?.
length
??
0
)
}
setHoveredIndex=
{
setHoveredIndex
}
toggleOpen=
{
toggleOpen
}
suggestions=
{
trendingCollections
as
unknown
as
GenieCollection
[]
}
...
...
@@ -286,7 +285,7 @@ export const SearchBarDropdown = ({ toggleOpen, tokens, collections, hasInput, i
hoveredIndex
,
phase1Flag
,
toggleOpen
,
s
earch
History
,
s
hortened
History
,
hasInput
,
isNFTPage
,
isTokenPage
,
...
...
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