Skip to content

Commit

Permalink
fix: enable display nft media from nft banner notice
Browse files Browse the repository at this point in the history
  • Loading branch information
sahar-fehri committed Jun 14, 2024
1 parent 7760571 commit 666362f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ function AutoDetectNftModal({ isOpen, onClose }: AutoDetectNftModalProps) {
},
});
if (val) {
dispatch(setUseNftDetection(val));
dispatch(setOpenSeaEnabled(val));
dispatch(setUseNftDetection(val));
}
onClose(val);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
import React from 'react';
import { useDispatch } from 'react-redux';
import { useDispatch, useSelector } from 'react-redux';
import { BannerAlert } from '../../component-library';
import { useI18nContext } from '../../../hooks/useI18nContext';
import {
detectNfts,
setOpenSeaEnabled,
setShowNftDetectionEnablementToast,
setUseNftDetection,
} from '../../../store/actions';
import { getOpenSeaEnabled } from '../../../selectors';

export default function NFTsDetectionNoticeNFTsTab() {
const t = useI18nContext();
const dispatch = useDispatch();
const isDisplayNFTMediaToggleEnabled = useSelector(getOpenSeaEnabled);

return (
<BannerAlert
className="nfts-detection-notice"
title={t('newNFTsAutodetected')}
actionButtonLabel={t('selectNFTPrivacyPreference')}
actionButtonOnClick={() => {
if (!isDisplayNFTMediaToggleEnabled) {
dispatch(setOpenSeaEnabled(true));
}
dispatch(setUseNftDetection(true));
// Show toast
dispatch(setShowNftDetectionEnablementToast(true));
Expand Down
4 changes: 4 additions & 0 deletions ui/components/app/nfts-tab/nfts-tab.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ const nftsDropdownState = {
const ACCOUNT_1 = '0x123';
const ACCOUNT_2 = '0x456';
const setUseNftDetectionStub = jest.fn();
const setDisplayNftMediaStub = jest.fn();

const render = ({
nftContracts = [],
Expand Down Expand Up @@ -224,6 +225,7 @@ describe('NFT Items', () => {
checkAndUpdateAllNftsOwnershipStatusStub,
updateNftDropDownState: updateNftDropDownStateStub,
setUseNftDetection: setUseNftDetectionStub,
setOpenSeaEnabled: setDisplayNftMediaStub,
});
const historyPushMock = jest.fn();

Expand Down Expand Up @@ -273,7 +275,9 @@ describe('NFT Items', () => {
});
fireEvent.click(screen.queryByText('Enable NFT Autodetection'));
expect(setUseNftDetectionStub).toHaveBeenCalledTimes(1);
expect(setDisplayNftMediaStub).toHaveBeenCalledTimes(1);
expect(setUseNftDetectionStub.mock.calls[0][0]).toStrictEqual(true);
expect(setDisplayNftMediaStub.mock.calls[0][0]).toStrictEqual(true);
});
it('should not render the NFTs Detection Notice when currently selected network is Mainnet and currently selected account has no NFTs but use NFT autodetection preference is set to true', () => {
render({
Expand Down

0 comments on commit 666362f

Please sign in to comment.