From 83e43386f26503cba18b9d1917f019feb431d90e Mon Sep 17 00:00:00 2001 From: nlyrthiia Date: Sun, 27 Nov 2022 08:55:41 +0800 Subject: [PATCH 1/2] feat: select_token_supports_uppercase_search --- src/components/UI/SearchToken/SearchToken.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/UI/SearchToken/SearchToken.js b/src/components/UI/SearchToken/SearchToken.js index eeef98d0..39aa709e 100644 --- a/src/components/UI/SearchToken/SearchToken.js +++ b/src/components/UI/SearchToken/SearchToken.js @@ -16,7 +16,15 @@ export const SearchToken = ({tokens, onSearchResults}) => { }; useEffect(() => { - const results = tokens.filter(token => token.name.toLowerCase().includes(searchTerm)); + const results = tokens.filter(token => { + const {name, symbol} = token; + const searchTermValue = searchTerm.toLowerCase(); + + return ( + name.toLowerCase().includes(searchTermValue) || + symbol.toLowerCase().includes(searchTermValue) + ); + }); onSearchResults(results); }, [searchTerm]); From c5af90494fcba155df238081f3437e0583445da3 Mon Sep 17 00:00:00 2001 From: nlyrthiia Date: Wed, 30 Nov 2022 00:08:37 +0800 Subject: [PATCH 2/2] fix: optimize iterator code --- src/components/UI/SearchToken/SearchToken.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/UI/SearchToken/SearchToken.js b/src/components/UI/SearchToken/SearchToken.js index 39aa709e..36557ef8 100644 --- a/src/components/UI/SearchToken/SearchToken.js +++ b/src/components/UI/SearchToken/SearchToken.js @@ -16,10 +16,10 @@ export const SearchToken = ({tokens, onSearchResults}) => { }; useEffect(() => { + const searchTermValue = searchTerm.toLowerCase(); + const results = tokens.filter(token => { const {name, symbol} = token; - const searchTermValue = searchTerm.toLowerCase(); - return ( name.toLowerCase().includes(searchTermValue) || symbol.toLowerCase().includes(searchTermValue)