Commit 45a5ca3b authored by Jordan Frankfurt's avatar Jordan Frankfurt Committed by GitHub

feat: sort supported chains to top of the chain selector list (#6800)

* feat: sort supported chains to top of the chain selector list

* pr feedback

---------
Co-authored-by: default avatarJordan Frankfurt <jordan@CORN-Jordan-949.frankfurt>
parent 54b4567a
...@@ -21,7 +21,7 @@ import { Box } from 'nft/components/Box' ...@@ -21,7 +21,7 @@ import { Box } from 'nft/components/Box'
import { Portal } from 'nft/components/common/Portal' import { Portal } from 'nft/components/common/Portal'
import { Column, Row } from 'nft/components/Flex' import { Column, Row } from 'nft/components/Flex'
import { useIsMobile } from 'nft/hooks' import { useIsMobile } from 'nft/hooks'
import { useCallback, useRef, useState } from 'react' import { useCallback, useMemo, useRef, useState } from 'react'
import { AlertTriangle, ChevronDown, ChevronUp } from 'react-feather' import { AlertTriangle, ChevronDown, ChevronUp } from 'react-feather'
import { useTheme } from 'styled-components/macro' import { useTheme } from 'styled-components/macro'
...@@ -69,9 +69,15 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => { ...@@ -69,9 +69,15 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => {
const theme = useTheme() const theme = useTheme()
const showTestnets = useAtomValue(showTestnetsAtom) const showTestnets = useAtomValue(showTestnetsAtom)
const chains = showTestnets const walletSupportsChain = useWalletSupportedChains()
? NETWORK_SELECTOR_CHAINS
: NETWORK_SELECTOR_CHAINS.filter((chain) => !TESTNET_CHAIN_IDS.has(chain)) const chains = useMemo(
() =>
NETWORK_SELECTOR_CHAINS.filter((chain) => showTestnets || !TESTNET_CHAIN_IDS.has(chain)).sort((a) =>
walletSupportsChain.includes(a) ? -1 : 1
),
[showTestnets, walletSupportsChain]
)
const ref = useRef<HTMLDivElement>(null) const ref = useRef<HTMLDivElement>(null)
const modalRef = useRef<HTMLDivElement>(null) const modalRef = useRef<HTMLDivElement>(null)
...@@ -94,8 +100,6 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => { ...@@ -94,8 +100,6 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => {
[selectChain, setIsOpen] [selectChain, setIsOpen]
) )
const walletSupportsChain = useWalletSupportedChains()
if (!chainId) { if (!chainId) {
return null return null
} }
......
...@@ -18,7 +18,7 @@ const Container = styled.button<{ disabled: boolean }>` ...@@ -18,7 +18,7 @@ const Container = styled.button<{ disabled: boolean }>`
display: grid; display: grid;
grid-template-columns: min-content 1fr min-content; grid-template-columns: min-content 1fr min-content;
justify-content: space-between; justify-content: space-between;
line-height: 24px; line-height: 20px;
opacity: ${({ disabled }) => (disabled ? 0.6 : 1)}; opacity: ${({ disabled }) => (disabled ? 0.6 : 1)};
padding: 10px 8px; padding: 10px 8px;
text-align: left; text-align: left;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment