Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Network filter must respect PORTFOLIO_VIEW feature flag #28626

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,6 @@
"redesignedTransactionsEnabled": "boolean",
"tokenSortConfig": "object",
"tokenNetworkFilter": {
"0x1": "boolean",
"0xaa36a7": "boolean",
"0xe705": "boolean",
"0xe708": "boolean",
"0x539": "boolean"
},
"shouldShowAggregatedBalancePopover": "boolean"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@
"redesignedTransactionsEnabled": "boolean",
"tokenSortConfig": "object",
"tokenNetworkFilter": {
"0x1": "boolean",
"0xaa36a7": "boolean",
"0xe705": "boolean",
"0xe708": "boolean",
"0x539": "boolean"
},
"shouldShowAggregatedBalancePopover": "boolean"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@
"tokenSortConfig": "object",
"tokenNetworkFilter": {},
"showMultiRpcModal": "boolean",
"shouldShowAggregatedBalancePopover": "boolean",
"tokenNetworkFilter": {}
"shouldShowAggregatedBalancePopover": "boolean"
},
"selectedAddress": "string",
"theme": "light",
Expand Down
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
Loading