Skip to content

Commit

Permalink
fix: When feature flag is off, we still need to filter by selected chain
Browse files Browse the repository at this point in the history
  • Loading branch information
gambinish committed Nov 21, 2024
1 parent 08cc205 commit aff551f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
}, []);

Expand Down
14 changes: 8 additions & 6 deletions ui/components/app/assets/token-list/token-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down

0 comments on commit aff551f

Please sign in to comment.