@@ -26,6 +26,7 @@ function HomeContent() {
2626 const { modalType, assetData, closeModal } = useModal ( ) ;
2727 const { setAccountTab } = useAccountTab ( ) ;
2828 const [ isConnected , setIsConnected ] = useState ( false ) ;
29+ const [ isCheckingConnection , setIsCheckingConnection ] = useState ( true ) ; // Add loading state
2930 const [ triggerConnect , setTriggerConnect ] = useState ( false ) ;
3031
3132 const { data : highestAPYData , isLoading : isApyLoading } = useHighestAPY ( ) ;
@@ -41,13 +42,23 @@ function HomeContent() {
4142 } catch ( error ) {
4243 console . error ( "Error checking wallet connection:" , error ) ;
4344 setIsConnected ( false ) ;
45+ } finally {
46+ setIsCheckingConnection ( false ) ; // Set loading to false after initial check
4447 }
4548 } ;
4649
4750 checkWalletConnection ( ) ;
4851
49- // Check connection status periodically
50- const interval = setInterval ( checkWalletConnection , 1000 ) ;
52+ // Check connection status periodically (but don't show loading after first check)
53+ const interval = setInterval ( async ( ) => {
54+ try {
55+ const connected = await checkConnection ( ) ;
56+ setIsConnected ( connected ) ;
57+ } catch ( error ) {
58+ console . error ( "Error checking wallet connection:" , error ) ;
59+ setIsConnected ( false ) ;
60+ }
61+ } , 1000 ) ;
5162
5263 return ( ) => clearInterval ( interval ) ;
5364 } , [ ] ) ;
@@ -63,6 +74,7 @@ function HomeContent() {
6374
6475 const handleWalletConnected = ( ) => {
6576 setIsConnected ( true ) ;
77+ setIsCheckingConnection ( false ) ; // Ensure loading state is cleared
6678 } ;
6779
6880 const handleConnectClick = ( ) => {
@@ -80,7 +92,8 @@ function HomeContent() {
8092 onWalletConnected = { handleWalletConnected }
8193 />
8294 < div className = { styles . body } >
83- { isConnected ? (
95+ { isCheckingConnection ? // Show nothing while checking connection
96+ null : isConnected ? (
8497 < div className = { styles . bodyContainer } >
8598 < div className = { styles . widgetContainer } >
8699 < div className = { styles . widgetLeftContainer } >
0 commit comments