11import { execute } from '@/graphql/execute' ;
22import { cn } from '@/lib/utils' ;
33import { useMutation } from '@tanstack/react-query' ;
4- import { useNavigate } from '@tanstack/react-router' ;
4+ import { useNavigate , useParams } from '@tanstack/react-router' ;
55import { Search } from 'lucide-react' ;
66import { useEffect , useRef , useState } from 'react' ;
77import { ChainLink } from '@/components/ChainLink' ;
88import { Button } from '@/components/ui/button' ;
99import { Input } from '@/components/ui/input' ;
1010import { getIExec , getReadonlyIExec } from '@/externals/iexecSdkClient' ;
1111import useUserStore from '@/stores/useUser.store' ;
12- import { getChainFromId } from '@/utils/chain.utils' ;
12+ import { getChainFromId , getChainFromSlug } from '@/utils/chain.utils' ;
1313import { searchQuery } from './searchQuery' ;
1414
1515export function SearcherBar ( {
@@ -19,13 +19,17 @@ export function SearcherBar({
1919 className ?: string ;
2020 initialSearch ?: string ;
2121} ) {
22- const { isConnected, address : userAddress , chainId } = useUserStore ( ) ;
22+ const { isConnected, address : userAddress } = useUserStore ( ) ;
2323 const [ inputValue , setInputValue ] = useState ( '' ) ;
2424 const [ shake , setShake ] = useState ( false ) ;
2525 const [ errorCount , setErrorCount ] = useState ( 0 ) ;
2626 const [ localError , setLocalError ] = useState < Error | null > ( null ) ;
2727 const inputRef = useRef < HTMLInputElement | null > ( null ) ;
2828
29+ // Get ChainId from URL to be faster when using URL search
30+ const { chainSlug } = useParams ( { from : '/$chainSlug' } ) ;
31+ const chainId = getChainFromSlug ( chainSlug ) ?. id ;
32+
2933 const navigate = useNavigate ( ) ;
3034
3135 const navigateToEntity = (
0 commit comments