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: Add nullish fallback for tokenNetwork filter Object.keys #28617

Closed
wants to merge 1 commit into from
Closed
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 @@ -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
Loading