diff --git a/ui/hooks/useTokenDetectionPolling.ts b/ui/hooks/useTokenDetectionPolling.ts index 790384e21cbf..d2e08d01892d 100644 --- a/ui/hooks/useTokenDetectionPolling.ts +++ b/ui/hooks/useTokenDetectionPolling.ts @@ -1,5 +1,6 @@ import { useSelector } from 'react-redux'; import { + getCurrentChainId, getNetworkConfigurationsByChainId, getUseTokenDetection, } from '../selectors'; @@ -17,14 +18,19 @@ const useTokenDetectionPolling = () => { const useTokenDetection = useSelector(getUseTokenDetection); const completedOnboarding = useSelector(getCompletedOnboarding); const isUnlocked = useSelector(getIsUnlocked); + const currentChainId = useSelector(getCurrentChainId); const networkConfigurations = useSelector(getNetworkConfigurationsByChainId); const enabled = completedOnboarding && isUnlocked && useTokenDetection; + const chainIds = process.env.PORTFOLIO_VIEW + ? Object.keys(networkConfigurations) + : [currentChainId]; + useMultiPolling({ startPolling: tokenDetectionStartPolling, stopPollingByPollingToken: tokenDetectionStopPollingByPollingToken, - input: enabled ? [Object.keys(networkConfigurations)] : [], + input: enabled ? [chainIds] : [], }); return {}; diff --git a/ui/hooks/useTokenRatesPolling.ts b/ui/hooks/useTokenRatesPolling.ts index a740a426e36c..37864ec89b82 100644 --- a/ui/hooks/useTokenRatesPolling.ts +++ b/ui/hooks/useTokenRatesPolling.ts @@ -1,5 +1,6 @@ import { useSelector } from 'react-redux'; import { + getCurrentChainId, getMarketData, getNetworkConfigurationsByChainId, getTokenExchangeRates, @@ -16,10 +17,11 @@ import { } from '../ducks/metamask/metamask'; import useMultiPolling from './useMultiPolling'; -const useTokenRatesPolling = ({ chainIds }: { chainIds?: string[] } = {}) => { +const useTokenRatesPolling = () => { // Selectors to determine polling input const completedOnboarding = useSelector(getCompletedOnboarding); const isUnlocked = useSelector(getIsUnlocked); + const currentChainId = useSelector(getCurrentChainId); const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck); const networkConfigurations = useSelector(getNetworkConfigurationsByChainId); @@ -30,10 +32,14 @@ const useTokenRatesPolling = ({ chainIds }: { chainIds?: string[] } = {}) => { const enabled = completedOnboarding && isUnlocked && useCurrencyRateCheck; + const chainIds = process.env.PORTFOLIO_VIEW + ? Object.keys(networkConfigurations) + : [currentChainId]; + useMultiPolling({ startPolling: tokenRatesStartPolling, stopPollingByPollingToken: tokenRatesStopPollingByPollingToken, - input: enabled ? chainIds ?? Object.keys(networkConfigurations) : [], + input: enabled ? chainIds : [], }); return {