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 dispatch detect Nfts on network switch #28769

Merged
merged 2 commits into from
Nov 27, 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 @@ -22,6 +22,7 @@ const mockSetActiveNetwork = jest.fn();
const mockUpdateCustomNonce = jest.fn();
const mockSetNextNonce = jest.fn();
const mockSetTokenNetworkFilter = jest.fn();
const mockDetectNfts = jest.fn();

jest.mock('../../../store/actions.ts', () => ({
setShowTestNetworks: () => mockSetShowTestNetworks,
Expand All @@ -32,6 +33,7 @@ jest.mock('../../../store/actions.ts', () => ({
setNetworkClientIdForDomain: (network, id) =>
mockSetNetworkClientIdForDomain(network, id),
setTokenNetworkFilter: () => mockSetTokenNetworkFilter,
detectNfts: () => mockDetectNfts,
}));

const MOCK_ORIGIN = 'https://portfolio.metamask.io';
Expand Down Expand Up @@ -218,6 +220,7 @@ describe('NetworkListMenu', () => {
expect(mockSetActiveNetwork).toHaveBeenCalled();
expect(mockUpdateCustomNonce).toHaveBeenCalled();
expect(mockSetNextNonce).toHaveBeenCalled();
expect(mockDetectNfts).toHaveBeenCalled();
});

it('shows the correct selected network when networks share the same chain ID', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
updateCustomNonce,
setNextNonce,
setTokenNetworkFilter,
detectNfts,
} from '../../../store/actions';
import {
CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP,
Expand Down Expand Up @@ -287,6 +288,7 @@ export const NetworkListMenu = ({ onClose }: { onClose: () => void }) => {
dispatch(toggleNetworkMenu());
dispatch(updateCustomNonce(''));
dispatch(setNextNonce(''));
dispatch(detectNfts());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are caching the calls to the NFT-API so its okay if this call is made multiple times

// as a user, I don't want my network selection to force update my filter when I have "All Networks" toggled on
// however, if I am already filtered on "Current Network", we'll want to filter by the selected network when the network changes
Expand Down
Loading