1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01: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: [],
recoveryPhraseReminderHasBeenShown: false,
recoveryPhraseReminderLastShown: new Date().getTime(),
collectiblesDetectionNoticeDismissed: false,
showTestnetMessageInDropdown: true,
showPortfolioTooltip: true,
showBetaHeader: isBeta(),
@ -303,19 +302,6 @@ export default class AppStateController extends EventEmitter {
this.store.updateState({ trezorModel });
}
/**
* A setter for the `collectiblesDetectionNoticeDismissed` property
*
* @param collectiblesDetectionNoticeDismissed
*/
setCollectiblesDetectionNoticeDismissed(
collectiblesDetectionNoticeDismissed,
) {
this.store.updateState({
collectiblesDetectionNoticeDismissed,
});
}
/**
* A setter for the `collectiblesDropdownState` property
*

View File

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

View File

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

View File

@ -13,7 +13,6 @@ import {
import { useI18nContext } from '../../../hooks/useI18nContext';
import Button from '../../ui/button';
import { EXPERIMENTAL_ROUTE } from '../../../helpers/constants/routes';
import { setCollectiblesDetectionNoticeDismissed } from '../../../store/actions';
export default function CollectiblesDetectionNotice() {
const t = useI18nContext();
@ -22,11 +21,6 @@ export default function CollectiblesDetectionNotice() {
return (
<Box className="collectibles-detection-notice">
<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 paddingTop={1}>
<i

View File

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

View File

@ -150,7 +150,6 @@ const render = ({
collectibles = [],
selectedAddress,
chainId = '0x1',
collectiblesDetectionNoticeDismissed = false,
useNftDetection,
onAddNFT = jest.fn(),
}) => {
@ -169,7 +168,6 @@ const render = ({
},
provider: { chainId },
selectedAddress,
collectiblesDetectionNoticeDismissed,
useNftDetection,
collectiblesDropdownState,
},
@ -179,13 +177,10 @@ const render = ({
describe('Collectible Items', () => {
const detectCollectiblesStub = jest.fn();
const setCollectiblesDetectionNoticeDismissedStub = jest.fn();
const getStateStub = jest.fn();
const checkAndUpdateAllCollectiblesOwnershipStatusStub = jest.fn();
const updateCollectibleDropDownStateStub = jest.fn();
setBackgroundConnection({
setCollectiblesDetectionNoticeDismissed:
setCollectiblesDetectionNoticeDismissedStub,
detectNfts: detectCollectiblesStub,
getState: getStateStub,
checkAndUpdateAllNftsOwnershipStatus:
@ -241,24 +236,9 @@ describe('Collectible Items', () => {
render({
selectedAddress: ACCOUNT_1,
collectibles: COLLECTIBLES,
collectiblesDetectionNoticeDismissed: true,
});
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', () => {

View File

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

View File

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

View File

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