1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Ensure that 'tokens found in this account' message is only shown when token detection activated (#15823)

This commit is contained in:
Dan J Miller 2022-09-14 13:05:14 -02:30 committed by GitHub
parent ba3a584d7f
commit b359844dc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 8 deletions

View File

@ -11,7 +11,7 @@ import {
getShouldShowFiat, getShouldShowFiat,
getNativeCurrencyImage, getNativeCurrencyImage,
getDetectedTokensInCurrentNetwork, getDetectedTokensInCurrentNetwork,
getIstokenDetectionInactiveOnNonMainnetSupportedNetwork, getDisplayDetectedTokensLink,
} from '../../../selectors'; } from '../../../selectors';
import { getNativeCurrency } from '../../../ducks/metamask/metamask'; import { getNativeCurrency } from '../../../ducks/metamask/metamask';
import { useCurrencyDisplay } from '../../../hooks/useCurrencyDisplay'; import { useCurrencyDisplay } from '../../../hooks/useCurrencyDisplay';
@ -66,9 +66,7 @@ const AssetList = ({ onClickAsset }) => {
const primaryTokenImage = useSelector(getNativeCurrencyImage); const primaryTokenImage = useSelector(getNativeCurrencyImage);
const detectedTokens = useSelector(getDetectedTokensInCurrentNetwork) || []; const detectedTokens = useSelector(getDetectedTokensInCurrentNetwork) || [];
const istokenDetectionInactiveOnNonMainnetSupportedNetwork = useSelector( const displayDetectedTokensLink = useSelector(getDisplayDetectedTokensLink);
getIstokenDetectionInactiveOnNonMainnetSupportedNetwork,
);
return ( return (
<> <>
@ -96,8 +94,7 @@ const AssetList = ({ onClickAsset }) => {
}); });
}} }}
/> />
{detectedTokens.length > 0 && {detectedTokens.length > 0 && displayDetectedTokensLink && (
!istokenDetectionInactiveOnNonMainnetSupportedNetwork && (
<DetectedTokensLink setShowDetectedTokens={setShowDetectedTokens} /> <DetectedTokensLink setShowDetectedTokens={setShowDetectedTokens} />
)} )}
<Box marginTop={detectedTokens.length > 0 ? 0 : 4}> <Box marginTop={detectedTokens.length > 0 ? 0 : 4}>

View File

@ -1122,6 +1122,21 @@ export function getIstokenDetectionInactiveOnNonMainnetSupportedNetwork(state) {
return isDynamicTokenListAvailable && !useTokenDetection && !isMainnet; return isDynamicTokenListAvailable && !useTokenDetection && !isMainnet;
} }
/**
* To check if the token detection is ON and either a dynamic list is available
* or the user is on mainnet
*
* @param {*} state
* @returns Boolean
*/
export function getDisplayDetectedTokensLink(state) {
const useTokenDetection = getUseTokenDetection(state);
const isMainnet = getIsMainnet(state);
const isDynamicTokenListAvailable = getIsDynamicTokenListAvailable(state);
return (isDynamicTokenListAvailable || isMainnet) && useTokenDetection;
}
/** /**
* To get the `customNetworkListEnabled` value which determines whether we use the custom network list * To get the `customNetworkListEnabled` value which determines whether we use the custom network list
* *