Commit 619c0a0f authored by vignesh mohankumar's avatar vignesh mohankumar Committed by GitHub

fix: sometimes show verified nft collections first (#5055)

* fix: sometimes show verified nft collections first

* simplify

* use showNfts logic

* rename

* use collections not trending
parent d4fb0913
...@@ -196,6 +196,12 @@ export const SearchBarDropdown = ({ ...@@ -196,6 +196,12 @@ export const SearchBarDropdown = ({
} }
}, [toggleOpen, hoveredIndex, totalSuggestions]) }, [toggleOpen, hoveredIndex, totalSuggestions])
const hasVerifiedCollection = collections.some((collection) => collection.isVerified)
const hasVerifiedToken = tokens.some((token) => token.onDefaultList)
const showCollectionsFirst =
(isNFTPage && (hasVerifiedCollection || !hasVerifiedToken)) ||
(!isNFTPage && !hasVerifiedToken && hasVerifiedCollection)
const trace = useTrace({ section: SectionName.NAVBAR_SEARCH }) const trace = useTrace({ section: SectionName.NAVBAR_SEARCH })
useEffect(() => { useEffect(() => {
...@@ -205,7 +211,7 @@ export const SearchBarDropdown = ({ ...@@ -205,7 +211,7 @@ export const SearchBarDropdown = ({
tokens.length > 0 ? ( tokens.length > 0 ? (
<SearchBarDropdownSection <SearchBarDropdownSection
hoveredIndex={hoveredIndex} hoveredIndex={hoveredIndex}
startingIndex={isNFTPage ? collections.length : 0} startingIndex={showCollectionsFirst ? collections.length : 0}
setHoveredIndex={setHoveredIndex} setHoveredIndex={setHoveredIndex}
toggleOpen={toggleOpen} toggleOpen={toggleOpen}
suggestions={tokens} suggestions={tokens}
...@@ -226,7 +232,7 @@ export const SearchBarDropdown = ({ ...@@ -226,7 +232,7 @@ export const SearchBarDropdown = ({
collections.length > 0 ? ( collections.length > 0 ? (
<SearchBarDropdownSection <SearchBarDropdownSection
hoveredIndex={hoveredIndex} hoveredIndex={hoveredIndex}
startingIndex={isNFTPage ? 0 : tokens.length} startingIndex={showCollectionsFirst ? 0 : tokens.length}
setHoveredIndex={setHoveredIndex} setHoveredIndex={setHoveredIndex}
toggleOpen={toggleOpen} toggleOpen={toggleOpen}
suggestions={collections} suggestions={collections}
...@@ -245,7 +251,7 @@ export const SearchBarDropdown = ({ ...@@ -245,7 +251,7 @@ export const SearchBarDropdown = ({
hasInput ? ( hasInput ? (
// Empty or Up to 8 combined tokens and nfts // Empty or Up to 8 combined tokens and nfts
<Column gap="20"> <Column gap="20">
{isNFTPage ? ( {showCollectionsFirst ? (
<> <>
{collectionSearchResults} {collectionSearchResults}
{tokenSearchResults} {tokenSearchResults}
...@@ -327,6 +333,7 @@ export const SearchBarDropdown = ({ ...@@ -327,6 +333,7 @@ export const SearchBarDropdown = ({
hasInput, hasInput,
isNFTPage, isNFTPage,
isTokenPage, isTokenPage,
showCollectionsFirst,
queryText, queryText,
totalSuggestions, totalSuggestions,
trace, trace,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment