|
3 | 3 | import { usePathname } from "next/navigation"; |
4 | 4 | import { useEffect } from "react"; |
5 | 5 | import { |
6 | | - arbitrumStylusTree, |
7 | | - ethereumEvmTree, |
8 | | - midnightTree, |
9 | | - polkadotTree, |
10 | | - starknetTree, |
11 | | - stellarTree, |
12 | | - uniswapTree, |
13 | | - zamaTree, |
| 6 | + arbitrumStylusTree, |
| 7 | + ethereumEvmTree, |
| 8 | + midnightTree, |
| 9 | + polkadotTree, |
| 10 | + starknetTree, |
| 11 | + stellarTree, |
| 12 | + uniswapTree, |
| 13 | + zamaTree, |
14 | 14 | } from "@/navigation"; |
15 | 15 |
|
16 | 16 | export function useNavigationTree() { |
17 | | - const pathname = usePathname(); |
| 17 | + const pathname = usePathname(); |
18 | 18 |
|
19 | | - // Track ecosystem changes in sessionStorage |
20 | | - useEffect(() => { |
21 | | - if (typeof window === "undefined") return; |
| 19 | + // Track ecosystem changes in sessionStorage |
| 20 | + useEffect(() => { |
| 21 | + if (typeof window === "undefined") return; |
22 | 22 |
|
23 | | - if (pathname.startsWith("/stellar-contracts")) { |
24 | | - sessionStorage.setItem("lastEcosystem", "stellar"); |
25 | | - } else if ( |
26 | | - pathname.startsWith("/contracts") || |
27 | | - pathname.startsWith("/community-contracts") || |
28 | | - pathname.startsWith("/upgrades-plugins") || |
29 | | - pathname.startsWith("/wizard") || |
30 | | - pathname.startsWith("/ui-builder") || |
31 | | - pathname.startsWith("/upgrades") || |
32 | | - pathname.startsWith("/defender") || |
33 | | - pathname.startsWith("/tools") |
34 | | - ) { |
35 | | - sessionStorage.setItem("lastEcosystem", "ethereum"); |
36 | | - } |
37 | | - }, [pathname]); |
| 23 | + if (pathname.startsWith("/stellar-contracts")) { |
| 24 | + sessionStorage.setItem("lastEcosystem", "stellar"); |
| 25 | + } else if (pathname.startsWith("/substrate-runtimes")) { |
| 26 | + sessionStorage.setItem("lastEcosystem", "polkadot"); |
| 27 | + } else if ( |
| 28 | + pathname.startsWith("/contracts") || |
| 29 | + pathname.startsWith("/community-contracts") || |
| 30 | + pathname.startsWith("/upgrades-plugins") || |
| 31 | + pathname.startsWith("/wizard") || |
| 32 | + pathname.startsWith("/ui-builder") || |
| 33 | + pathname.startsWith("/upgrades") || |
| 34 | + pathname.startsWith("/defender") || |
| 35 | + pathname.startsWith("/tools") |
| 36 | + ) { |
| 37 | + sessionStorage.setItem("lastEcosystem", "ethereum"); |
| 38 | + } |
| 39 | + }, [pathname]); |
38 | 40 |
|
39 | | - // Determine which navigation tree to use based on the current path |
40 | | - if (pathname.startsWith("/contracts-stylus")) { |
41 | | - return arbitrumStylusTree; |
42 | | - } else if (pathname.startsWith("/contracts-cairo")) { |
43 | | - return starknetTree; |
44 | | - } else if (pathname.startsWith("/stellar-contracts")) { |
45 | | - return stellarTree; |
46 | | - } else if (pathname.startsWith("/contracts-compact")) { |
47 | | - return midnightTree; |
48 | | - } else if (pathname.startsWith("/confidential-contracts")) { |
49 | | - return zamaTree; |
50 | | - } else if (pathname.startsWith("/uniswap-hooks")) { |
51 | | - return uniswapTree; |
52 | | - } else if (pathname.startsWith("/substrate-runtimes")) { |
53 | | - return polkadotTree; |
54 | | - } else if (pathname.startsWith("/tools")) { |
55 | | - return ethereumEvmTree; |
56 | | - } |
| 41 | + // Determine which navigation tree to use based on the current path |
| 42 | + if (pathname.startsWith("/contracts-stylus")) { |
| 43 | + return arbitrumStylusTree; |
| 44 | + } else if (pathname.startsWith("/contracts-cairo")) { |
| 45 | + return starknetTree; |
| 46 | + } else if (pathname.startsWith("/stellar-contracts")) { |
| 47 | + return stellarTree; |
| 48 | + } else if (pathname.startsWith("/contracts-compact")) { |
| 49 | + return midnightTree; |
| 50 | + } else if (pathname.startsWith("/confidential-contracts")) { |
| 51 | + return zamaTree; |
| 52 | + } else if (pathname.startsWith("/uniswap-hooks")) { |
| 53 | + return uniswapTree; |
| 54 | + } else if (pathname.startsWith("/substrate-runtimes")) { |
| 55 | + return polkadotTree; |
| 56 | + } else if (pathname.startsWith("/tools")) { |
| 57 | + return ethereumEvmTree; |
| 58 | + } |
57 | 59 |
|
58 | | - // For shared paths like /monitor and /relayer, check sessionStorage to see |
59 | | - // which ecosystem was last active, defaulting to ethereumEvmTree |
60 | | - if (typeof window !== "undefined") { |
61 | | - const lastEcosystem = sessionStorage.getItem("lastEcosystem"); |
| 60 | + // For shared paths like /monitor and /relayer, check sessionStorage to see |
| 61 | + // which ecosystem was last active, defaulting to ethereumEvmTree |
| 62 | + if (typeof window !== "undefined") { |
| 63 | + const lastEcosystem = sessionStorage.getItem("lastEcosystem"); |
62 | 64 |
|
63 | | - if (pathname.startsWith("/monitor") || pathname.startsWith("/relayer")) { |
64 | | - switch (lastEcosystem) { |
65 | | - case "stellar": |
66 | | - return stellarTree; |
67 | | - case "ethereum": |
68 | | - return ethereumEvmTree; |
69 | | - default: |
70 | | - return ethereumEvmTree; |
71 | | - } |
72 | | - } |
73 | | - } |
| 65 | + if (pathname.startsWith("/monitor") || pathname.startsWith("/relayer")) { |
| 66 | + switch (lastEcosystem) { |
| 67 | + case "stellar": |
| 68 | + return stellarTree; |
| 69 | + case "polkadot": |
| 70 | + return polkadotTree; |
| 71 | + case "ethereum": |
| 72 | + return ethereumEvmTree; |
| 73 | + default: |
| 74 | + return ethereumEvmTree; |
| 75 | + } |
| 76 | + } |
| 77 | + } |
74 | 78 |
|
75 | | - // Default to ethereumEvmTree for other paths |
76 | | - return ethereumEvmTree; |
| 79 | + // Default to ethereumEvmTree for other paths |
| 80 | + return ethereumEvmTree; |
77 | 81 | } |
0 commit comments