Skip to content

Commit

Permalink
use feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
bergeron committed Nov 14, 2024
1 parent 4a77428 commit 4095e64
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
6 changes: 2 additions & 4 deletions app/components/UI/Tokens/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -243,15 +243,13 @@ const Tokens: React.FC<TokensI> = ({ tokens }) => {
const onActionSheetPress = (index: number) =>
index === 0 ? removeToken() : null;

const isTokenFilterEnabled = process.env.PORTFOLIO_VIEW === 'true';

return (
<View
style={styles.wrapper}
testID={WalletViewSelectorsIDs.TOKENS_CONTAINER}
>
<View style={styles.actionBarWrapper}>
{isTokenFilterEnabled ? (
{isPortfolioViewEnabled ? (
<View style={styles.controlButtonOuterWrapper}>
<ButtonBase
label={
Expand Down
10 changes: 8 additions & 2 deletions app/components/hooks/AssetPolling/useTokenRatesPolling.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
import { useSelector } from 'react-redux';
import usePolling from '../usePolling';
import Engine from '../../../core/Engine';
import { selectNetworkConfigurations } from '../../../selectors/networkController';
import { selectChainId, selectNetworkConfigurations } from '../../../selectors/networkController';
import { Hex } from '@metamask/utils';
import { selectContractExchangeRates, selectTokenMarketData } from '../../../selectors/tokenRatesController';
import { isPortfolioViewEnabled } from '../../../util/networks';

const useTokenRatesPolling = ({ chainIds }: { chainIds?: Hex[] } = {}) => {

// 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({
startPolling:
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 {
Expand Down
3 changes: 3 additions & 0 deletions app/util/networks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

0 comments on commit 4095e64

Please sign in to comment.