From 884cdaddc259608efc42a4a7c742898295dcfbba Mon Sep 17 00:00:00 2001 From: Matthew Wall Date: Thu, 23 May 2024 21:50:26 -0400 Subject: [PATCH] filter out assets from curated assets with no icon_url --- .../screens/Swap/components/TokenList/TokenToBuySection.tsx | 2 +- src/__swaps__/screens/Swap/hooks/useSearchCurrencyLists.ts | 3 ++- src/__swaps__/screens/Swap/resources/_selectors/search.ts | 5 +++++ src/__swaps__/screens/Swap/resources/search/index.ts | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 src/__swaps__/screens/Swap/resources/_selectors/search.ts diff --git a/src/__swaps__/screens/Swap/components/TokenList/TokenToBuySection.tsx b/src/__swaps__/screens/Swap/components/TokenList/TokenToBuySection.tsx index dae690ff913..67a8837b0d8 100644 --- a/src/__swaps__/screens/Swap/components/TokenList/TokenToBuySection.tsx +++ b/src/__swaps__/screens/Swap/components/TokenList/TokenToBuySection.tsx @@ -130,7 +130,7 @@ export const TokenToBuySection = ({ section }: { section: AssetToBuySection }) = {/* TODO: fix this from causing the UI to be completely slow... */} } keyExtractor={item => `${item.uniqueId}-${section.id}`} renderItem={({ item }) => ( diff --git a/src/__swaps__/screens/Swap/hooks/useSearchCurrencyLists.ts b/src/__swaps__/screens/Swap/hooks/useSearchCurrencyLists.ts index cdce8218591..bb64cf358e6 100644 --- a/src/__swaps__/screens/Swap/hooks/useSearchCurrencyLists.ts +++ b/src/__swaps__/screens/Swap/hooks/useSearchCurrencyLists.ts @@ -14,6 +14,7 @@ import { isAddress } from '@ethersproject/address'; import { RainbowToken } from '@/entities'; import { useSwapContext } from '../providers/swap-provider'; import { userAssetsStore } from '@/state/assets/userAssets'; +import { filterNonTokenIconAssets } from '../resources/_selectors/search'; export type AssetToBuySectionId = 'bridge' | 'favorites' | 'verified' | 'unverified' | 'other_networks'; @@ -75,7 +76,7 @@ export function useSearchCurrencyLists() { // static search data const { data: verifiedAssets, isLoading: verifiedAssetsLoading } = useTokenSearch( { list: 'verifiedAssets' }, - { staleTime: 60 * 60 * 1000, cacheTime: 24 * 60 * 60 * 1000 } + { select: filterNonTokenIconAssets, staleTime: 60 * 60 * 1000, cacheTime: 24 * 60 * 60 * 1000 } ); // current search diff --git a/src/__swaps__/screens/Swap/resources/_selectors/search.ts b/src/__swaps__/screens/Swap/resources/_selectors/search.ts new file mode 100644 index 00000000000..ad3c61cc2e8 --- /dev/null +++ b/src/__swaps__/screens/Swap/resources/_selectors/search.ts @@ -0,0 +1,5 @@ +import { TokenSearchResult } from '../search'; + +export function filterNonTokenIconAssets(tokens: TokenSearchResult) { + return tokens.filter(token => token.icon_url); +} diff --git a/src/__swaps__/screens/Swap/resources/search/index.ts b/src/__swaps__/screens/Swap/resources/search/index.ts index f7e60c0fe08..6d71bd93bee 100644 --- a/src/__swaps__/screens/Swap/resources/search/index.ts +++ b/src/__swaps__/screens/Swap/resources/search/index.ts @@ -130,7 +130,7 @@ function parseTokenSearch(assets: SearchAsset[], chainId?: ChainId) { } } -type TokenSearchResult = QueryFunctionResult; +export type TokenSearchResult = QueryFunctionResult; // /////////////////////////////////////////////// // Query Fetcher