Skip to content

Commit 84e610b

Browse files
committed
lint fix
1 parent 26adc39 commit 84e610b

File tree

2 files changed

+43
-50
lines changed

2 files changed

+43
-50
lines changed

src/components/ChainSelector/ChainSelector.tsx

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function ChainSelector({
2323
onNetworkTypeChange,
2424
dataFeedType = "default",
2525
availableNetworkTypes = { mainnet: true, testnet: true },
26-
selectedNetworkType: externalSelectedNetworkType
26+
selectedNetworkType: externalSelectedNetworkType,
2727
}: ChainSelectorProps) {
2828
const [isOpen, setIsOpen] = useState(false)
2929
const [selectedNetworkType, setSelectedNetworkType] = useState<"mainnet" | "testnet">(
@@ -43,13 +43,14 @@ export function ChainSelector({
4343
if (dataFeedType.includes("streams")) return chain.tags?.includes("streams") ?? false
4444
if (dataFeedType === "smartdata") return chain.tags?.includes("smartData") ?? false
4545
if (dataFeedType === "rates") return chain.tags?.includes("rates") ?? false
46-
if (dataFeedType === "usGovernmentMacroeconomicData") return chain.tags?.includes("usGovernmentMacroeconomicData") ?? false
46+
if (dataFeedType === "usGovernmentMacroeconomicData")
47+
return chain.tags?.includes("usGovernmentMacroeconomicData") ?? false
4748
return chain.tags?.includes("default") ?? false
4849
})()
49-
50+
5051
// Filter by search term
5152
const matchesSearch = !searchTerm || chain.label.toLowerCase().includes(searchTerm.toLowerCase())
52-
53+
5354
return matchesDataFeedType && matchesSearch
5455
})
5556

@@ -71,20 +72,16 @@ export function ChainSelector({
7172
}
7273
}, [isOpen, focusedIndex, filteredChains])
7374

74-
75-
7675
// Scroll focused item into view
7776
useEffect(() => {
7877
if (focusedIndex >= 0 && chainOptionsRef.current[focusedIndex]) {
7978
chainOptionsRef.current[focusedIndex]?.scrollIntoView({
80-
behavior: 'smooth',
81-
block: 'nearest'
79+
behavior: "smooth",
80+
block: "nearest",
8281
})
8382
}
8483
}, [focusedIndex])
8584

86-
87-
8885
const toggleDropdown = () => {
8986
setIsOpen(!isOpen)
9087
if (!isOpen) {
@@ -111,19 +108,19 @@ export function ChainSelector({
111108
switch (e.key) {
112109
case "ArrowDown":
113110
e.preventDefault()
114-
setFocusedIndex(prev => (prev < filteredChains.length - 1 ? prev + 1 : prev))
111+
setFocusedIndex((prev) => (prev < filteredChains.length - 1 ? prev + 1 : prev))
115112
break
116113
case "ArrowUp":
117114
e.preventDefault()
118-
setFocusedIndex(prev => (prev > 0 ? prev - 1 : prev))
115+
setFocusedIndex((prev) => (prev > 0 ? prev - 1 : prev))
119116
break
120117
case "PageDown":
121118
e.preventDefault()
122-
setFocusedIndex(prev => Math.min(prev + 5, filteredChains.length - 1))
119+
setFocusedIndex((prev) => Math.min(prev + 5, filteredChains.length - 1))
123120
break
124121
case "PageUp":
125122
e.preventDefault()
126-
setFocusedIndex(prev => Math.max(prev - 5, 0))
123+
setFocusedIndex((prev) => Math.max(prev - 5, 0))
127124
break
128125
case "Enter":
129126
e.preventDefault()
@@ -142,7 +139,7 @@ export function ChainSelector({
142139

143140
const handleNetworkTypeToggle = (networkType: "mainnet" | "testnet") => {
144141
setSelectedNetworkType(networkType)
145-
142+
146143
// Notify parent component about the network type change
147144
if (onNetworkTypeChange) {
148145
onNetworkTypeChange(networkType, selectedChain)
@@ -160,13 +157,13 @@ export function ChainSelector({
160157
type="button"
161158
>
162159
<div className={styles.selectedChain}>
163-
<img
164-
src={selectedChain.img}
165-
alt={`${selectedChain.label} icon`}
166-
className={styles.chainIcon}
167-
width={28}
168-
height={28}
169-
/>
160+
<img
161+
src={selectedChain.img}
162+
alt={`${selectedChain.label} icon`}
163+
className={styles.chainIcon}
164+
width={28}
165+
height={28}
166+
/>
170167
<span className={styles.chainLabel}>{selectedChain.label}</span>
171168
</div>
172169
<div className={clsx(styles.caret, isOpen && styles.caretOpen)}>
@@ -184,7 +181,9 @@ export function ChainSelector({
184181
)}
185182
onClick={() => availableNetworkTypes.mainnet && handleNetworkTypeToggle("mainnet")}
186183
disabled={!availableNetworkTypes.mainnet}
187-
title={!availableNetworkTypes.mainnet ? `${selectedChain.label} feeds are not available on mainnet` : undefined}
184+
title={
185+
!availableNetworkTypes.mainnet ? `${selectedChain.label} feeds are not available on mainnet` : undefined
186+
}
188187
>
189188
Mainnet
190189
</button>
@@ -197,7 +196,9 @@ export function ChainSelector({
197196
)}
198197
onClick={() => availableNetworkTypes.testnet && handleNetworkTypeToggle("testnet")}
199198
disabled={!availableNetworkTypes.testnet}
200-
title={!availableNetworkTypes.testnet ? `${selectedChain.label} feeds are not available on testnet` : undefined}
199+
title={
200+
!availableNetworkTypes.testnet ? `${selectedChain.label} feeds are not available on testnet` : undefined
201+
}
201202
>
202203
Testnet
203204
</button>
@@ -269,14 +270,12 @@ export function ChainSelector({
269270
</button>
270271
))}
271272
{filteredChains.length === 0 && (
272-
<div className={styles.noResults}>
273-
No chains found matching "{searchTerm}"
274-
</div>
273+
<div className={styles.noResults}>No chains found matching "{searchTerm}"</div>
275274
)}
276275
</div>
277276
</div>
278277
</div>
279278
)}
280279
</div>
281280
)
282-
}
281+
}

src/features/feeds/components/FeedList.tsx

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const FeedList = ({
6262

6363
// Initialize state with the URL value
6464
const [currentNetwork, setCurrentNetwork] = useState(effectiveInitialNetwork)
65-
65+
6666
// Get network directly from URL or fall back to initialNetwork
6767
const getNetworkFromURL = () => {
6868
if (typeof window === "undefined") return initialNetwork
@@ -115,7 +115,7 @@ export const FeedList = ({
115115
}
116116

117117
// If window is already loaded, run immediately
118-
if (document.readyState === 'complete') {
118+
if (document.readyState === "complete") {
119119
handleLoad()
120120
} else {
121121
window.addEventListener("load", handleLoad)
@@ -126,10 +126,10 @@ export const FeedList = ({
126126

127127
// Track the selected network type (mainnet/testnet)
128128
const [selectedNetworkType, setSelectedNetworkType] = useState<"mainnet" | "testnet">("mainnet")
129-
129+
130130
// Track hydration to prevent SSR mismatch
131131
const [isHydrated, setIsHydrated] = useState(false)
132-
132+
133133
useEffect(() => {
134134
setIsHydrated(true)
135135
}, [])
@@ -188,7 +188,7 @@ export const FeedList = ({
188188
]
189189
const [streamsChain] = useState(initialNetwork)
190190
const activeChain = isStreams ? streamsChain : currentNetwork
191-
191+
192192
// More robust chain finding - ensure we have a valid chain
193193
const chain = useMemo(() => {
194194
// During SSR, if we don't have an activeChain but we have a network param in the URL,
@@ -207,7 +207,7 @@ export const FeedList = ({
207207
}
208208
return chains[0] // fallback only if no activeChain
209209
}
210-
210+
211211
const foundChain = chains.find((c) => c.page === activeChain)
212212
if (!foundChain) {
213213
return chains[0]
@@ -220,28 +220,28 @@ export const FeedList = ({
220220
// Determine available network types for the current chain
221221
const availableNetworkTypes = useMemo(() => {
222222
if (!chainMetadata.processedData?.networks) return { mainnet: false, testnet: false }
223-
223+
224224
const networkTypes = {
225225
mainnet: false,
226-
testnet: false
226+
testnet: false,
227227
}
228-
228+
229229
chainMetadata.processedData.networks.forEach((network) => {
230230
if (network.networkType === "mainnet") {
231231
networkTypes.mainnet = true
232232
} else if (network.networkType === "testnet") {
233233
networkTypes.testnet = true
234234
}
235235
})
236-
236+
237237
return networkTypes
238238
}, [chainMetadata.processedData?.networks])
239239

240240
// Auto-adjust selectedNetworkType based on what's available
241241
useEffect(() => {
242242
if (!chainMetadata.loading && chainMetadata.processedData) {
243243
const { mainnet, testnet } = availableNetworkTypes
244-
244+
245245
// If current selection is not available, switch to what's available
246246
if (selectedNetworkType === "mainnet" && !mainnet && testnet) {
247247
setSelectedNetworkType("testnet")
@@ -388,7 +388,7 @@ export const FeedList = ({
388388
function handleNetworkTypeChange(networkType: "mainnet" | "testnet", chain: Chain) {
389389
// Update the selected network type
390390
setSelectedNetworkType(networkType)
391-
391+
392392
// Reset filters and pagination when switching network types
393393
setSearchValue("")
394394
setTestnetSearchValue("")
@@ -413,8 +413,6 @@ export const FeedList = ({
413413
}
414414
}
415415

416-
417-
418416
useEffect(() => {
419417
if (searchValue === "") {
420418
const searchParams = new URLSearchParams(window.location.search)
@@ -488,8 +486,6 @@ export const FeedList = ({
488486
}
489487
}, [searchValue, testnetSearchValue, chainMetadata.loading])
490488

491-
492-
493489
if (
494490
dataFeedType === "streamsCrypto" ||
495491
dataFeedType === "streamsRwa" ||
@@ -682,16 +678,14 @@ export const FeedList = ({
682678

683679
return (
684680
<SectionWrapper title="Networks" depth={2} updateTOC={false}>
685-
686-
687681
{!isDeprecating && (
688682
<>
689-
<div
690-
className={feedList.clChainnavProduct}
691-
style={{
683+
<div
684+
className={feedList.clChainnavProduct}
685+
style={{
692686
marginBottom: "var(--space-4x)",
693687
justifyContent: "flex-start",
694-
flexWrap: "nowrap"
688+
flexWrap: "nowrap",
695689
}}
696690
>
697691
{isHydrated && (

0 commit comments

Comments
 (0)