Skip to content

Commit

Permalink
Merge branch 'develop' into MMPD-1363
Browse files Browse the repository at this point in the history
  • Loading branch information
ziad-saab authored Nov 14, 2024
2 parents a498e91 + 1c8bfff commit 05d9935
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@ export const ImportTokensModal = ({ onClose }) => {
return (
<Modal
isOpen
isClosedOnOutsideClick={false}
onClose={() => {
dispatch(clearPendingTokens());
onClose();
Expand Down
10 changes: 8 additions & 2 deletions ui/hooks/useCurrencyRatePolling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@ import {
currencyRateStartPolling,
currencyRateStopPollingByPollingToken,
} from '../store/actions';
import { getCompletedOnboarding } from '../ducks/metamask/metamask';
import {
getCompletedOnboarding,
getIsUnlocked,
} from '../ducks/metamask/metamask';
import usePolling from './usePolling';

const useCurrencyRatePolling = () => {
const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck);
const completedOnboarding = useSelector(getCompletedOnboarding);
const isUnlocked = useSelector(getIsUnlocked);
const networkConfigurations = useSelector(getNetworkConfigurationsByChainId);

const enabled = completedOnboarding && isUnlocked && useCurrencyRateCheck;

const nativeCurrencies = [
...new Set(
Object.values(networkConfigurations).map((n) => n.nativeCurrency),
Expand All @@ -25,7 +31,7 @@ const useCurrencyRatePolling = () => {
startPolling: currencyRateStartPolling,
stopPollingByPollingToken: currencyRateStopPollingByPollingToken,
input: nativeCurrencies,
enabled: useCurrencyRateCheck && completedOnboarding,
enabled,
});
};

Expand Down
12 changes: 9 additions & 3 deletions ui/hooks/useTokenRatesPolling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@ import {
tokenRatesStartPolling,
tokenRatesStopPollingByPollingToken,
} from '../store/actions';
import {
getCompletedOnboarding,
getIsUnlocked,
} from '../ducks/metamask/metamask';
import useMultiPolling from './useMultiPolling';

const useTokenRatesPolling = ({ chainIds }: { chainIds?: string[] } = {}) => {
// Selectors to determine polling input
const completedOnboarding = useSelector(getCompletedOnboarding);
const isUnlocked = useSelector(getIsUnlocked);
const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck);
const networkConfigurations = useSelector(getNetworkConfigurationsByChainId);

Expand All @@ -22,12 +28,12 @@ const useTokenRatesPolling = ({ chainIds }: { chainIds?: string[] } = {}) => {
const tokensMarketData = useSelector(getTokensMarketData);
const marketData = useSelector(getMarketData);

const enabled = completedOnboarding && isUnlocked && useCurrencyRateCheck;

useMultiPolling({
startPolling: tokenRatesStartPolling,
stopPollingByPollingToken: tokenRatesStopPollingByPollingToken,
input: useCurrencyRateCheck
? chainIds ?? Object.keys(networkConfigurations)
: [],
input: enabled ? chainIds ?? Object.keys(networkConfigurations) : [],
});

return {
Expand Down

0 comments on commit 05d9935

Please sign in to comment.