From d633b9732a259620545f7f04dd1ec446b9b9332a Mon Sep 17 00:00:00 2001 From: David Walsh Date: Wed, 27 Sep 2023 12:57:02 -0500 Subject: [PATCH] Fix #20934 - Show network icon in New Network popover (#21016) Fixes #20934 This PR ensures the correct network icon displays when switching to a new network like Optimism and Arbitrum. While ETH may be the native currency of each of those networks, the chip image should represent the network. --------- Co-authored-by: Howard Braham --- .../ui/new-network-info/new-network-info.js | 69 +++++++------------ 1 file changed, 23 insertions(+), 46 deletions(-) diff --git a/ui/components/ui/new-network-info/new-network-info.js b/ui/components/ui/new-network-info/new-network-info.js index e1da41051d82..fac443c44c00 100644 --- a/ui/components/ui/new-network-info/new-network-info.js +++ b/ui/components/ui/new-network-info/new-network-info.js @@ -1,11 +1,10 @@ -import React, { useContext, useEffect, useState, useCallback } from 'react'; +import React, { useCallback, useContext, useEffect, useState } from 'react'; import { useSelector } from 'react-redux'; import { useHistory } from 'react-router-dom'; +import { TOKEN_API_METASWAP_CODEFI_URL } from '../../../../shared/constants/tokens'; +import fetchWithCache from '../../../../shared/lib/fetch-with-cache'; import { I18nContext } from '../../../contexts/i18n'; -import Popover from '../popover'; -import Button from '../button'; -import Identicon from '../identicon'; -import Box from '../box'; +import { getProviderConfig } from '../../../ducks/metamask/metamask'; import { AlignItems, Color, @@ -14,29 +13,23 @@ import { TextAlign, TextVariant, } from '../../../helpers/constants/design-system'; -import { TOKEN_API_METASWAP_CODEFI_URL } from '../../../../shared/constants/tokens'; -import fetchWithCache from '../../../../shared/lib/fetch-with-cache'; -import { - getNativeCurrencyImage, - getUseTokenDetection, -} from '../../../selectors'; -import { getProviderConfig } from '../../../ducks/metamask/metamask'; import { IMPORT_TOKEN_ROUTE } from '../../../helpers/constants/routes'; -import Chip from '../chip/chip'; +import { getCurrentNetwork, getUseTokenDetection } from '../../../selectors'; import { setFirstTimeUsedNetwork } from '../../../store/actions'; -import { NETWORK_TYPES } from '../../../../shared/constants/network'; -import { Icon, IconName, Text } from '../../component-library'; -import { getNetworkLabelKey } from '../../../helpers/utils/i18n-helper'; +import { PickerNetwork, Text } from '../../component-library'; +import Box from '../box'; +import Button from '../button'; +import Popover from '../popover'; -const NewNetworkInfo = () => { +export default function NewNetworkInfo() { const t = useContext(I18nContext); const history = useHistory(); const [tokenDetectionSupported, setTokenDetectionSupported] = useState(false); const [showPopup, setShowPopup] = useState(true); const [isLoading, setIsLoading] = useState(true); const autoDetectToken = useSelector(getUseTokenDetection); - const primaryTokenImage = useSelector(getNativeCurrencyImage); const providerConfig = useSelector(getProviderConfig); + const currentNetwork = useSelector(getCurrentNetwork); const onCloseClick = () => { setShowPopup(false); @@ -95,29 +88,15 @@ const NewNetworkInfo = () => { > {t('switchedTo')} - - ) : ( - - ) - } + { {t('thingsToKeep')} - {providerConfig.ticker ? ( + {providerConfig.ticker && ( { ])} - ) : null} + )} { ) ); -}; - -export default NewNetworkInfo; +}