@@ -3,23 +3,24 @@ import { useBlockQuery, useNonFungibleTokensQuery, useTransactionQuery } from '.
33import useAccounts from './useAccounts' ;
44
55const useSearch = ( query : string ) => {
6+ const trimedQuery = query . trim ( )
67 const { data : blockData , loading : blockIsLoading } = useBlockQuery ( {
78 variables : {
8- id : query ,
9+ id : trimedQuery ,
910 } ,
1011 } ) ;
1112 const { data : txData , loading : txIsLoading } = useTransactionQuery ( {
1213 variables : {
13- id : query ,
14+ id : trimedQuery ,
1415 } ,
1516 } ) ;
16- const { data : accountData , isLoading : accountIsLoading } = useAccounts ( query ) ;
17+ const { data : accountData , isLoading : accountIsLoading } = useAccounts ( trimedQuery ) ;
1718
1819 const { data : NFTCollectionData , loading : NFTCollectionLoading } = useNonFungibleTokensQuery ( {
1920 fetchPolicy : 'no-cache' ,
2021 variables : {
2122 where : {
22- token_in : [ query , query ? query . toLowerCase ( ) : "" ]
23+ token_in : [ trimedQuery , trimedQuery ? trimedQuery . toLowerCase ( ) : "" ]
2324 } ,
2425 first : 1 ,
2526 } ,
@@ -32,7 +33,7 @@ const useSearch = (query: string) => {
3233 React . useEffect ( ( ) => {
3334 setResultLoaded ( false ) ;
3435 setResults ( [ ] ) ;
35- } , [ query ] ) ;
36+ } , [ trimedQuery ] ) ;
3637 console . log ( 'results' , results )
3738
3839 React . useEffect ( ( ) => {
@@ -72,7 +73,7 @@ const useSearch = (query: string) => {
7273 setResults ( allResults ) ;
7374 setResultLoaded ( true ) ;
7475 }
75- } , [ blockIsLoading , blockData , txIsLoading , txData , accountIsLoading , accountData , NFTCollectionData , NFTCollectionLoading , query ] ) ;
76+ } , [ blockIsLoading , blockData , txIsLoading , txData , accountIsLoading , accountData , NFTCollectionData , NFTCollectionLoading , trimedQuery ] ) ;
7677
7778 return {
7879 loaded : resultLoaded ,
0 commit comments