Skip to content

Commit

Permalink
fix empty search catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
Melisa Anabella Rossi committed Oct 27, 2023
1 parent f46a4a7 commit 3365f09
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 27 deletions.
12 changes: 6 additions & 6 deletions webapp/src/components/AssetTopbar/AssetTopbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,17 @@ export const AssetTopbar = ({
value?: string
contractAddresses?: string[]
}) => {
if (value !== undefined && search !== value) {
onBrowse({
search: value,
section: category ? getSectionFromCategory(category) : section
})
} else if (contractAddresses && contractAddresses.length) {
if (contractAddresses && contractAddresses.length) {
onBrowse({
contracts: contractAddresses,
search: ''
})
handleClearSearch()
} else if (search !== value) {
onBrowse({
search: value,
section: category ? getSectionFromCategory(category) : section
})
}
setShouldRenderSearchDropdown(false)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,6 @@ export const SearchBarDropdown = ({
onFetchCreators,
onClickOutside
}: SearchBarDropdownProps) => {
const [searchUUID, setSearchUUID] = useState(
uuidv5(searchTerm, UUID_NAMESPACE)
)

// assigns a UUID to the search term to link the events of rendering the results with the search term selected
useEffect(() => {
setSearchUUID(uuidv5(searchTerm, UUID_NAMESPACE))
}, [searchTerm])

const isSearchingWearables = category === NFTCategory.WEARABLE
const isSearchingEmotes = category === NFTCategory.EMOTE

Expand Down Expand Up @@ -114,9 +105,6 @@ export const SearchBarDropdown = ({
)

const handleSeeAll = useCallback(() => {
if (!searchTerm) {
return
}
if (
currentSearchTab === SearchTab.EMOTES ||
currentSearchTab === SearchTab.WEARABLES
Expand All @@ -125,7 +113,7 @@ export const SearchBarDropdown = ({
getAnalytics().track(events.SEARCH_ALL, {
tab: currentSearchTab,
searchTerm,
searchUUID
searchUUID: uuidv5(searchTerm, UUID_NAMESPACE)
})
} else if (currentSearchTab === SearchTab.COLLECTIONS) {
const contractAddresses = (results as BuilderCollectionAttributes[]).map(
Expand All @@ -137,7 +125,7 @@ export const SearchBarDropdown = ({
searchTerm
})
}
}, [currentSearchTab, onSearch, results, searchTerm, searchUUID])
}, [currentSearchTab, onSearch, results, searchTerm])

// handle the enter key press and trigger the See all feature
useEffect(() => {
Expand All @@ -159,6 +147,7 @@ export const SearchBarDropdown = ({
useEffect(() => {
let cancel = false
if (searchTerm) {
const searchUUID = uuidv5(searchTerm, UUID_NAMESPACE)
if (
currentSearchTab === SearchTab.EMOTES ||
currentSearchTab === SearchTab.WEARABLES
Expand Down Expand Up @@ -226,7 +215,6 @@ export const SearchBarDropdown = ({
searchTerm,
isSearchingEmotes,
isSearchingWearables,
searchUUID,
onFetchCreators
])

Expand All @@ -252,11 +240,11 @@ export const SearchBarDropdown = ({
getAnalytics().track(events.SEARCH_RESULT_CLICKED, {
searchTerm,
item_id: collectible.id,
search_uuid: searchUUID,
search_uuid: uuidv5(searchTerm, UUID_NAMESPACE),
item_position: index
})
},
[handleSaveToLocalStorage, searchTerm, searchUUID]
[handleSaveToLocalStorage, searchTerm]
)

const renderCollectiblesSearch = useCallback(() => {
Expand Down Expand Up @@ -311,11 +299,11 @@ export const SearchBarDropdown = ({
getAnalytics().track(events.SEARCH_RESULT_CLICKED, {
searchTerm,
wallet_id: creator.address,
search_uuid: searchUUID,
search_uuid: uuidv5(searchTerm, UUID_NAMESPACE),
item_position: index
})
},
[handleSaveToLocalStorage, searchTerm, searchUUID]
[handleSaveToLocalStorage, searchTerm]
)

const renderCreatorsSearch = useCallback(() => {
Expand Down Expand Up @@ -346,11 +334,11 @@ export const SearchBarDropdown = ({
getAnalytics().track(events.SEARCH_RESULT_CLICKED, {
searchTerm,
collection_id: collection.contract_address,
search_uuid: searchUUID,
search_uuid: uuidv5(searchTerm, UUID_NAMESPACE),
item_position: index
})
},
[handleSaveToLocalStorage, onSearch, searchTerm, searchUUID]
[handleSaveToLocalStorage, onSearch, searchTerm]
)

const renderCollectionsSearch = useCallback(() => {
Expand Down

0 comments on commit 3365f09

Please sign in to comment.