1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 11:22:43 +02:00

Fix #17388 - Remove dismiss button from NFT notification (#17389)

This commit is contained in:
David Walsh 2023-01-25 13:28:15 -06:00 committed by GitHub
parent a4f968b423
commit 29d4799f46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 3 additions and 73 deletions

View File

@ -33,7 +33,6 @@ export default class AppStateController extends EventEmitter {
fullScreenGasPollTokens: [], fullScreenGasPollTokens: [],
recoveryPhraseReminderHasBeenShown: false, recoveryPhraseReminderHasBeenShown: false,
recoveryPhraseReminderLastShown: new Date().getTime(), recoveryPhraseReminderLastShown: new Date().getTime(),
collectiblesDetectionNoticeDismissed: false,
showTestnetMessageInDropdown: true, showTestnetMessageInDropdown: true,
showPortfolioTooltip: true, showPortfolioTooltip: true,
showBetaHeader: isBeta(), showBetaHeader: isBeta(),
@ -303,19 +302,6 @@ export default class AppStateController extends EventEmitter {
this.store.updateState({ trezorModel }); this.store.updateState({ trezorModel });
} }
/**
* A setter for the `collectiblesDetectionNoticeDismissed` property
*
* @param collectiblesDetectionNoticeDismissed
*/
setCollectiblesDetectionNoticeDismissed(
collectiblesDetectionNoticeDismissed,
) {
this.store.updateState({
collectiblesDetectionNoticeDismissed,
});
}
/** /**
* A setter for the `collectiblesDropdownState` property * A setter for the `collectiblesDropdownState` property
* *

View File

@ -1864,10 +1864,6 @@ export default class MetamaskController extends EventEmitter {
appStateController.setShowPortfolioTooltip.bind(appStateController), appStateController.setShowPortfolioTooltip.bind(appStateController),
setShowBetaHeader: setShowBetaHeader:
appStateController.setShowBetaHeader.bind(appStateController), appStateController.setShowBetaHeader.bind(appStateController),
setCollectiblesDetectionNoticeDismissed:
appStateController.setCollectiblesDetectionNoticeDismissed.bind(
appStateController,
),
updateCollectibleDropDownState: updateCollectibleDropDownState:
appStateController.updateCollectibleDropDownState.bind( appStateController.updateCollectibleDropDownState.bind(
appStateController, appStateController,

View File

@ -115,7 +115,6 @@ function defaultFixture() {
}, },
AppStateController: { AppStateController: {
browserEnvironment: {}, browserEnvironment: {},
collectiblesDetectionNoticeDismissed: false,
collectiblesDropdownState: {}, collectiblesDropdownState: {},
connectedStatusPopoverHasBeenShown: true, connectedStatusPopoverHasBeenShown: true,
defaultHomeActiveTabName: null, defaultHomeActiveTabName: null,
@ -282,7 +281,6 @@ function onboardingFixture() {
data: { data: {
AppStateController: { AppStateController: {
browserEnvironment: {}, browserEnvironment: {},
collectiblesDetectionNoticeDismissed: false,
collectiblesDropdownState: {}, collectiblesDropdownState: {},
connectedStatusPopoverHasBeenShown: true, connectedStatusPopoverHasBeenShown: true,
defaultHomeActiveTabName: null, defaultHomeActiveTabName: null,

View File

@ -13,7 +13,6 @@ import {
import { useI18nContext } from '../../../hooks/useI18nContext'; import { useI18nContext } from '../../../hooks/useI18nContext';
import Button from '../../ui/button'; import Button from '../../ui/button';
import { EXPERIMENTAL_ROUTE } from '../../../helpers/constants/routes'; import { EXPERIMENTAL_ROUTE } from '../../../helpers/constants/routes';
import { setCollectiblesDetectionNoticeDismissed } from '../../../store/actions';
export default function CollectiblesDetectionNotice() { export default function CollectiblesDetectionNotice() {
const t = useI18nContext(); const t = useI18nContext();
@ -22,11 +21,6 @@ export default function CollectiblesDetectionNotice() {
return ( return (
<Box className="collectibles-detection-notice"> <Box className="collectibles-detection-notice">
<Dialog type="message" className="collectibles-detection-notice__message"> <Dialog type="message" className="collectibles-detection-notice__message">
<button
onClick={() => setCollectiblesDetectionNoticeDismissed()}
className="fas fa-times collectibles-detection-notice__message__close-button"
data-testid="collectibles-detection-notice-close"
/>
<Box display={DISPLAY.FLEX}> <Box display={DISPLAY.FLEX}>
<Box paddingTop={1}> <Box paddingTop={1}>
<i <i

View File

@ -17,7 +17,6 @@ import {
ALIGN_ITEMS, ALIGN_ITEMS,
} from '../../../helpers/constants/design-system'; } from '../../../helpers/constants/design-system';
import { useI18nContext } from '../../../hooks/useI18nContext'; import { useI18nContext } from '../../../hooks/useI18nContext';
import { getCollectiblesDetectionNoticeDismissed } from '../../../ducks/metamask/metamask';
import { getIsMainnet, getUseNftDetection } from '../../../selectors'; import { getIsMainnet, getUseNftDetection } from '../../../selectors';
import { EXPERIMENTAL_ROUTE } from '../../../helpers/constants/routes'; import { EXPERIMENTAL_ROUTE } from '../../../helpers/constants/routes';
import { import {
@ -30,9 +29,6 @@ import ZENDESK_URLS from '../../../helpers/constants/zendesk-url';
export default function CollectiblesTab({ onAddNFT }) { export default function CollectiblesTab({ onAddNFT }) {
const useNftDetection = useSelector(getUseNftDetection); const useNftDetection = useSelector(getUseNftDetection);
const isMainnet = useSelector(getIsMainnet); const isMainnet = useSelector(getIsMainnet);
const collectibleDetectionNoticeDismissed = useSelector(
getCollectiblesDetectionNoticeDismissed,
);
const history = useHistory(); const history = useHistory();
const t = useI18nContext(); const t = useI18nContext();
const dispatch = useDispatch(); const dispatch = useDispatch();
@ -65,9 +61,7 @@ export default function CollectiblesTab({ onAddNFT }) {
/> />
) : ( ) : (
<> <>
{isMainnet && {isMainnet && !useNftDetection ? (
!useNftDetection &&
!collectibleDetectionNoticeDismissed ? (
<CollectiblesDetectionNotice /> <CollectiblesDetectionNotice />
) : null} ) : null}
<Box padding={12}> <Box padding={12}>

View File

@ -150,7 +150,6 @@ const render = ({
collectibles = [], collectibles = [],
selectedAddress, selectedAddress,
chainId = '0x1', chainId = '0x1',
collectiblesDetectionNoticeDismissed = false,
useNftDetection, useNftDetection,
onAddNFT = jest.fn(), onAddNFT = jest.fn(),
}) => { }) => {
@ -169,7 +168,6 @@ const render = ({
}, },
provider: { chainId }, provider: { chainId },
selectedAddress, selectedAddress,
collectiblesDetectionNoticeDismissed,
useNftDetection, useNftDetection,
collectiblesDropdownState, collectiblesDropdownState,
}, },
@ -179,13 +177,10 @@ const render = ({
describe('Collectible Items', () => { describe('Collectible Items', () => {
const detectCollectiblesStub = jest.fn(); const detectCollectiblesStub = jest.fn();
const setCollectiblesDetectionNoticeDismissedStub = jest.fn();
const getStateStub = jest.fn(); const getStateStub = jest.fn();
const checkAndUpdateAllCollectiblesOwnershipStatusStub = jest.fn(); const checkAndUpdateAllCollectiblesOwnershipStatusStub = jest.fn();
const updateCollectibleDropDownStateStub = jest.fn(); const updateCollectibleDropDownStateStub = jest.fn();
setBackgroundConnection({ setBackgroundConnection({
setCollectiblesDetectionNoticeDismissed:
setCollectiblesDetectionNoticeDismissedStub,
detectNfts: detectCollectiblesStub, detectNfts: detectCollectiblesStub,
getState: getStateStub, getState: getStateStub,
checkAndUpdateAllNftsOwnershipStatus: checkAndUpdateAllNftsOwnershipStatus:
@ -241,24 +236,9 @@ describe('Collectible Items', () => {
render({ render({
selectedAddress: ACCOUNT_1, selectedAddress: ACCOUNT_1,
collectibles: COLLECTIBLES, collectibles: COLLECTIBLES,
collectiblesDetectionNoticeDismissed: true,
}); });
expect(screen.queryByText('New! NFT detection')).not.toBeInTheDocument(); expect(screen.queryByText('New! NFT detection')).not.toBeInTheDocument();
}); });
it('should call setCollectibesDetectionNoticeDismissed when users clicks "X"', () => {
render({
selectedAddress: ACCOUNT_2,
collectibles: COLLECTIBLES,
});
expect(
setCollectiblesDetectionNoticeDismissedStub,
).not.toHaveBeenCalled();
fireEvent.click(
screen.queryByTestId('collectibles-detection-notice-close'),
);
expect(setCollectiblesDetectionNoticeDismissedStub).toHaveBeenCalled();
});
}); });
describe('Collections', () => { describe('Collections', () => {

View File

@ -266,10 +266,6 @@ export const getPendingTokens = (state) => state.metamask.pendingTokens;
export const getTokens = (state) => state.metamask.tokens; export const getTokens = (state) => state.metamask.tokens;
export function getCollectiblesDetectionNoticeDismissed(state) {
return state.metamask.collectiblesDetectionNoticeDismissed;
}
export function getCollectiblesDropdownState(state) { export function getCollectiblesDropdownState(state) {
return state.metamask.collectiblesDropdownState; return state.metamask.collectiblesDropdownState;
} }

View File

@ -28,10 +28,7 @@ import {
getSelectedAddress, getSelectedAddress,
getUseNftDetection, getUseNftDetection,
} from '../../selectors'; } from '../../selectors';
import { import { getCollectiblesDropdownState } from '../../ducks/metamask/metamask';
getCollectiblesDetectionNoticeDismissed,
getCollectiblesDropdownState,
} from '../../ducks/metamask/metamask';
import CollectiblesDetectionNotice from '../../components/app/collectibles-detection-notice'; import CollectiblesDetectionNotice from '../../components/app/collectibles-detection-notice';
import { MetaMetricsContext } from '../../contexts/metametrics'; import { MetaMetricsContext } from '../../contexts/metametrics';
import { AssetType } from '../../../shared/constants/transaction'; import { AssetType } from '../../../shared/constants/transaction';
@ -43,9 +40,6 @@ export default function AddCollectible() {
const dispatch = useDispatch(); const dispatch = useDispatch();
const useNftDetection = useSelector(getUseNftDetection); const useNftDetection = useSelector(getUseNftDetection);
const isMainnet = useSelector(getIsMainnet); const isMainnet = useSelector(getIsMainnet);
const collectibleDetectionNoticeDismissed = useSelector(
getCollectiblesDetectionNoticeDismissed,
);
const collectiblesDropdownState = useSelector(getCollectiblesDropdownState); const collectiblesDropdownState = useSelector(getCollectiblesDropdownState);
const selectedAddress = useSelector(getSelectedAddress); const selectedAddress = useSelector(getSelectedAddress);
const chainId = useSelector(getCurrentChainId); const chainId = useSelector(getCurrentChainId);
@ -145,9 +139,7 @@ export default function AddCollectible() {
disabled={disabled} disabled={disabled}
contentComponent={ contentComponent={
<Box> <Box>
{isMainnet && {isMainnet && !useNftDetection ? (
!useNftDetection &&
!collectibleDetectionNoticeDismissed ? (
<CollectiblesDetectionNotice /> <CollectiblesDetectionNotice />
) : null} ) : null}
{collectibleAddFailed && ( {collectibleAddFailed && (

View File

@ -3805,12 +3805,6 @@ export function hideBetaHeader() {
return submitRequestToBackground('setShowBetaHeader', [false]); return submitRequestToBackground('setShowBetaHeader', [false]);
} }
export function setCollectiblesDetectionNoticeDismissed() {
return submitRequestToBackground('setCollectiblesDetectionNoticeDismissed', [
true,
]);
}
export function setTransactionSecurityCheckEnabled( export function setTransactionSecurityCheckEnabled(
transactionSecurityCheckEnabled, transactionSecurityCheckEnabled,
) { ) {