Skip to content

Commit b6576e5

Browse files
committed
more cleanup
1 parent eed2ce3 commit b6576e5

File tree

2 files changed

+12
-33
lines changed

2 files changed

+12
-33
lines changed

src/components/ChainSelector/ChainSelector.tsx

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,7 @@ export function ChainSelector({
7171
}
7272
}, [isOpen, focusedIndex, filteredChains])
7373

74-
// Sync with external selectedNetworkType
75-
useEffect(() => {
76-
if (externalSelectedNetworkType && externalSelectedNetworkType !== selectedNetworkType) {
77-
setSelectedNetworkType(externalSelectedNetworkType)
78-
}
79-
}, [externalSelectedNetworkType])
74+
8075

8176
// Scroll focused item into view
8277
useEffect(() => {
@@ -88,10 +83,7 @@ export function ChainSelector({
8883
}
8984
}, [focusedIndex])
9085

91-
// Reset refs array when filtered chains change
92-
useEffect(() => {
93-
chainOptionsRef.current = []
94-
}, [filteredChains])
86+
9587

9688
const toggleDropdown = () => {
9789
setIsOpen(!isOpen)
@@ -151,21 +143,9 @@ export function ChainSelector({
151143
const handleNetworkTypeToggle = (networkType: "mainnet" | "testnet") => {
152144
setSelectedNetworkType(networkType)
153145

154-
// Find a network of the selected type for the current chain
155-
const targetNetwork = selectedChain.networks.find(network => network.networkType === networkType)
156-
if (targetNetwork) {
157-
// Update URL to show the correct network
158-
if (typeof window !== "undefined" && !dataFeedType.includes("streams")) {
159-
const params = new URLSearchParams(window.location.search)
160-
params.set("network", selectedChain.page)
161-
const newUrl = window.location.pathname + "?" + params.toString()
162-
window.history.replaceState({ path: newUrl }, "", newUrl)
163-
}
164-
165-
// Notify parent component about the network type change
166-
if (onNetworkTypeChange) {
167-
onNetworkTypeChange(networkType, selectedChain)
168-
}
146+
// Notify parent component about the network type change
147+
if (onNetworkTypeChange) {
148+
onNetworkTypeChange(networkType, selectedChain)
169149
}
170150
}
171151

src/features/feeds/components/FeedList.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ export const FeedList = ({
5757
// Initialize state with the URL value
5858
const [currentNetwork, setCurrentNetwork] = useState(effectiveInitialNetwork)
5959

60-
// Track the selected network type (mainnet/testnet)
61-
const [selectedNetworkType, setSelectedNetworkType] = useState<"mainnet" | "testnet">("mainnet")
62-
6360
// Get network directly from URL or fall back to initialNetwork
6461
const getNetworkFromURL = () => {
6562
if (typeof window === "undefined") return initialNetwork
@@ -109,6 +106,9 @@ export const FeedList = ({
109106
}
110107
}, [])
111108

109+
// Track the selected network type (mainnet/testnet)
110+
const [selectedNetworkType, setSelectedNetworkType] = useState<"mainnet" | "testnet">("mainnet")
111+
112112
// Regular query string states
113113
const [searchValue, setSearchValue] = useQueryString("search", "")
114114
const [testnetSearchValue, setTestnetSearchValue] = useQueryString("testnetSearch", "")
@@ -363,6 +363,8 @@ export const FeedList = ({
363363
}
364364
}
365365

366+
367+
366368
useEffect(() => {
367369
if (searchValue === "") {
368370
const searchParams = new URLSearchParams(window.location.search)
@@ -436,10 +438,7 @@ export const FeedList = ({
436438
}
437439
}, [searchValue, testnetSearchValue, chainMetadata.loading])
438440

439-
// handles button selection based on URL - simplified since we now use dropdown
440-
const NetworkSelectionUpdater = () => {
441-
return null
442-
}
441+
443442

444443
if (
445444
dataFeedType === "streamsCrypto" ||
@@ -633,7 +632,7 @@ export const FeedList = ({
633632

634633
return (
635634
<SectionWrapper title="Networks" depth={2} updateTOC={false}>
636-
<NetworkSelectionUpdater />
635+
637636

638637
{!isDeprecating && (
639638
<>

0 commit comments

Comments
 (0)