From 78f74151c774761be3abaeb9acd62013db7c1dcf Mon Sep 17 00:00:00 2001 From: jinchung Date: Mon, 30 Dec 2024 12:53:13 -0500 Subject: [PATCH] Filter out favorites from all networks results --- src/hooks/useSearchCurrencyList.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/hooks/useSearchCurrencyList.ts b/src/hooks/useSearchCurrencyList.ts index f99e8bcdbb1..05bbd0650b1 100644 --- a/src/hooks/useSearchCurrencyList.ts +++ b/src/hooks/useSearchCurrencyList.ts @@ -37,7 +37,7 @@ const abcSort = (list: any[], key?: string) => { const useSearchCurrencyList = (searchQuery: string) => { const searching = useMemo(() => searchQuery !== '', [searchQuery]); - const { favoritesMetadata: favoriteMap } = useFavorites(); + const { favorites: favoriteAddresses, favoritesMetadata: favoriteMap } = useFavorites(); const unfilteredFavorites = useMemo(() => { return Object.values(favoriteMap) .filter(token => token.networks[ChainId.mainnet]) @@ -104,9 +104,13 @@ const useSearchCurrencyList = (searchQuery: string) => { }) .slice(0, MAX_VERIFIED_RESULTS); - return [...topResults]; + const topResultsWithoutFavorites = topResults.filter(asset => { + return !favoriteAddresses.map(a => a?.toLowerCase()).includes(asset.address?.toLowerCase()); + }); + + return [...topResultsWithoutFavorites]; }, - [searchQuery] + [searchQuery, favoriteAddresses] ); const { data: searchResultAssets, isFetching: loading } = useTokenSearchAllNetworks(