diff --git a/app/components/UI/Tokens/index.tsx b/app/components/UI/Tokens/index.tsx index 7248812d461..c87c8b843ce 100644 --- a/app/components/UI/Tokens/index.tsx +++ b/app/components/UI/Tokens/index.tsx @@ -13,7 +13,7 @@ import { selectChainId, selectNetworkConfigurations, } from '../../../selectors/networkController'; -import { getDecimalChainId } from '../../../util/networks'; +import { getDecimalChainId, isPortfolioViewEnabled } from '../../../util/networks'; import { isZero } from '../../../util/lodash'; import createStyles from './styles'; import { TokenList } from './TokenList'; @@ -243,15 +243,13 @@ const Tokens: React.FC = ({ tokens }) => { const onActionSheetPress = (index: number) => index === 0 ? removeToken() : null; - const isTokenFilterEnabled = process.env.PORTFOLIO_VIEW === 'true'; - return ( - {isTokenFilterEnabled ? ( + {isPortfolioViewEnabled ? ( { // Selectors to determine polling input const networkConfigurations = useSelector(selectNetworkConfigurations); + const currentChainId = useSelector(selectChainId); // Selectors returning state updated by the polling const contractExchangeRates = useSelector(selectContractExchangeRates); const tokenMarketData = useSelector(selectTokenMarketData); + const chainIdsToPoll = isPortfolioViewEnabled + ? [currentChainId] + : (chainIds ?? Object.keys(networkConfigurations)); + const { TokenRatesController } = Engine.context; usePolling({ @@ -21,7 +27,7 @@ const useTokenRatesPolling = ({ chainIds }: { chainIds?: Hex[] } = {}) => { TokenRatesController.startPolling.bind(TokenRatesController), stopPollingByPollingToken: TokenRatesController.stopPollingByPollingToken.bind(TokenRatesController), - input: (chainIds ?? Object.keys(networkConfigurations)).map((chainId) => ({chainId: chainId as Hex})), + input: chainIdsToPoll.map((chainId) => ({chainId: chainId as Hex})), }); return { diff --git a/app/util/networks/index.js b/app/util/networks/index.js index 62491502031..b05627467d4 100644 --- a/app/util/networks/index.js +++ b/app/util/networks/index.js @@ -592,3 +592,6 @@ export const isChainPermissionsFeatureEnabled = export const isPermissionsSettingsV1Enabled = process.env.MM_PERMISSIONS_SETTINGS_V1_ENABLED === '1'; + +export const isPortfolioViewEnabled = + process.env.PORTFOLIO_VIEW === 'true';