|
1 | 1 | import { Box, Container } from '@mui/material'; |
2 | | -import { useRouter } from 'next/router'; |
3 | | -import { ReactNode, useEffect, useRef } from 'react'; |
4 | | -import { ROUTES } from 'src/components/primitives/Link'; |
| 2 | +import { ReactNode, useEffect } from 'react'; |
5 | 3 | import { MainLayout } from 'src/layouts/MainLayout'; |
6 | | -import { useWeb3Context } from 'src/libs/hooks/useWeb3Context'; |
7 | 4 | import { MarketAssetsListContainer } from 'src/modules/markets/MarketAssetsListContainer'; |
8 | 5 | import { MarketsTopPanel } from 'src/modules/markets/MarketsTopPanel'; |
9 | 6 | import { useRootStore } from 'src/store/root'; |
@@ -41,32 +38,7 @@ export const MarketContainer = ({ children }: MarketContainerProps) => { |
41 | 38 | }; |
42 | 39 |
|
43 | 40 | export default function Markets() { |
44 | | - const router = useRouter(); |
45 | | - const { currentAccount } = useWeb3Context(); |
46 | 41 | const trackEvent = useRootStore((store) => store.trackEvent); |
47 | | - const prevAccountRef = useRef<string | undefined>(); |
48 | | - const isInitialMount = useRef(true); |
49 | | - |
50 | | - // Redirect to dashboard only when wallet gets connected (not when already connected) |
51 | | - useEffect(() => { |
52 | | - // Skip the initial mount to avoid redirecting when already connected |
53 | | - if (isInitialMount.current) { |
54 | | - isInitialMount.current = false; |
55 | | - prevAccountRef.current = currentAccount; |
56 | | - return; |
57 | | - } |
58 | | - |
59 | | - const wasConnected = !!prevAccountRef.current; |
60 | | - const isConnected = !!currentAccount; |
61 | | - |
62 | | - // Only redirect if wallet was not connected before but is now connected |
63 | | - if (!wasConnected && isConnected) { |
64 | | - router.replace(ROUTES.dashboard); |
65 | | - } |
66 | | - |
67 | | - // Update the ref for next comparison |
68 | | - prevAccountRef.current = currentAccount; |
69 | | - }, [currentAccount, router]); |
70 | 42 |
|
71 | 43 | useEffect(() => { |
72 | 44 | trackEvent('Page Viewed', { |
|
0 commit comments