From aff551f0f103bfe258bec9d68386425d12f1793c Mon Sep 17 00:00:00 2001 From: Nicholas Gambino Date: Thu, 21 Nov 2024 12:27:31 -0800 Subject: [PATCH] fix: When feature flag is off, we still need to filter by selected chain --- .../asset-list-control-bar.tsx | 7 ++++++- ui/components/app/assets/token-list/token-list.tsx | 14 ++++++++------ .../network-list-menu/network-list-menu.tsx | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ui/components/app/assets/asset-list/asset-list-control-bar/asset-list-control-bar.tsx b/ui/components/app/assets/asset-list/asset-list-control-bar/asset-list-control-bar.tsx index e5c43aad281d..a09b5128396a 100644 --- a/ui/components/app/assets/asset-list/asset-list-control-bar/asset-list-control-bar.tsx +++ b/ui/components/app/assets/asset-list/asset-list-control-bar/asset-list-control-bar.tsx @@ -87,8 +87,13 @@ const AssetListControlBar = ({ showTokensLinks }: AssetListControlBarProps) => { // We need to set the default filter for all users to be all included networks, rather than defaulting to empty object // This effect is to unblock and derisk in the short-term useEffect(() => { - if (Object.keys(tokenNetworkFilter || {}).length === 0) { + if ( + process.env.PORTFOLIO_VIEW && + Object.keys(tokenNetworkFilter || {}).length === 0 + ) { dispatch(setTokenNetworkFilter(allOpts)); + } else { + dispatch(setTokenNetworkFilter({ [currentNetwork.chainId]: true })); } }, []); diff --git a/ui/components/app/assets/token-list/token-list.tsx b/ui/components/app/assets/token-list/token-list.tsx index 3f094634743e..5e25c7ff5f41 100644 --- a/ui/components/app/assets/token-list/token-list.tsx +++ b/ui/components/app/assets/token-list/token-list.tsx @@ -112,12 +112,14 @@ export default function TokenList({ // Ensure newly added networks are included in the tokenNetworkFilter useEffect(() => { - const allNetworkFilters = Object.fromEntries( - Object.keys(allNetworks).map((chainId) => [chainId, true]), - ); - - if (Object.keys(tokenNetworkFilter).length > 1) { - dispatch(setTokenNetworkFilter(allNetworkFilters)); + if (process.env.PORTFOLIO_VIEW) { + const allNetworkFilters = Object.fromEntries( + Object.keys(allNetworks).map((chainId) => [chainId, true]), + ); + + if (Object.keys(tokenNetworkFilter).length > 1) { + dispatch(setTokenNetworkFilter(allNetworkFilters)); + } } }, [Object.keys(allNetworks).length]); diff --git a/ui/components/multichain/network-list-menu/network-list-menu.tsx b/ui/components/multichain/network-list-menu/network-list-menu.tsx index 4dcecbf696e7..9c99b3048a95 100644 --- a/ui/components/multichain/network-list-menu/network-list-menu.tsx +++ b/ui/components/multichain/network-list-menu/network-list-menu.tsx @@ -292,7 +292,7 @@ export const NetworkListMenu = ({ onClose }: { onClose: () => void }) => { // however, if I am already filtered on "Current Network", we'll want to filter by the selected network when the network changes if (Object.keys(tokenNetworkFilter).length <= 1) { dispatch(setTokenNetworkFilter({ [network.chainId]: true })); - } else { + } else if (process.env.PORTFOLIO_VIEW) { dispatch(setTokenNetworkFilter(allOpts)); }