Skip to content

Commit

Permalink
fix: Add nullish fallback for tokenNetwork filter Object.keys
Browse files Browse the repository at this point in the history
  • Loading branch information
gambinish committed Nov 21, 2024
1 parent c20ac99 commit 7625322
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ const AssetListControlBar = ({ showTokensLinks }: AssetListControlBarProps) => {
}, [currentNetwork.chainId, TEST_CHAINS]);

const allOpts: Record<string, boolean> = {};
Object.keys(allNetworks).forEach((chainId) => {
Object.keys(allNetworks || {}).forEach((chainId) => {
allOpts[chainId] = true;
});

const allNetworksFilterShown =
Object.keys(tokenNetworkFilter).length !== Object.keys(allOpts).length;
Object.keys(tokenNetworkFilter ?? {}).length !==
Object.keys(allOpts ?? {}).length;

useEffect(() => {
if (isTestNetwork) {
Expand All @@ -86,18 +87,18 @@ 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 (Object.keys(tokenNetworkFilter ?? {}).length === 0) {
dispatch(setTokenNetworkFilter(allOpts));
}
}, []);

// When a network gets added/removed we want to make sure that we switch to the filtered list of the current network
// We only want to do this if the "Current Network" filter is selected
useEffect(() => {
if (Object.keys(tokenNetworkFilter).length === 1) {
if (Object.keys(tokenNetworkFilter ?? {}).length === 1) {
dispatch(setTokenNetworkFilter({ [currentNetwork.chainId]: true }));
}
}, [Object.keys(allNetworks).length]);
}, [Object.keys(allNetworks ?? {}).length]);

const windowType = getEnvironmentType();
const isFullScreen =
Expand Down

0 comments on commit 7625322

Please sign in to comment.