1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-25 20:02:58 +01:00

Fix: show whats new to users who created, not imported, a new wallet,… (#16042)

* Fix: show whats new to users who created, not imported, a new wallet, but not on their first session

* Fix tests

Hide `Improved token detection is here` & `Scam and security risks`  whats new

* Fix unit test

Co-authored-by: PeterYinusa <peter.yinusa@consensys.net>
This commit is contained in:
Dan J Miller 2022-10-04 13:22:42 -02:30 committed by seaona
parent efd1c4d806
commit b69dcdf7c2
8 changed files with 30 additions and 3 deletions

View File

@ -53,6 +53,12 @@
"8": {
"isShown": true
},
"10": {
"isShown": true
},
"11": {
"isShown": true
},
"12": {
"isShown": true
},

View File

@ -62,6 +62,7 @@ export default function reduceApp(state = {}, action) {
sendInputCurrencySwitched: false,
newTokensImported: '',
newCustomNetworkAdded: {},
onboardedInThisUISession: false,
...state,
};
@ -406,6 +407,11 @@ export default function reduceApp(state = {}, action) {
...appState,
newCustomNetworkAdded: action.value,
};
case actionConstants.ONBOARDED_IN_THIS_UI_SESSION:
return {
...appState,
onboardedInThisUISession: action.value,
};
default:
return appState;
}
@ -471,3 +477,7 @@ export function toggleCurrencySwitch() {
export function setNewCustomNetworkAdded(value) {
return { type: actionConstants.SET_NEW_CUSTOM_NETWORK_ADDED, value };
}
export function setOnBoardedInThisUISession(value) {
return { type: actionConstants.ONBOARDED_IN_THIS_UI_SESSION, value };
}

View File

@ -17,6 +17,7 @@ export default class EndOfFlowScreen extends PureComponent {
static contextTypes = {
t: PropTypes.func,
trackEvent: PropTypes.func,
setOnBoardedInThisUISession: PropTypes.func,
};
static propTypes = {
@ -26,6 +27,7 @@ export default class EndOfFlowScreen extends PureComponent {
location: PropTypes.string,
tabId: PropTypes.number,
}),
setOnBoardedInThisUISession: PropTypes.func,
};
async _beforeUnload() {
@ -37,7 +39,8 @@ export default class EndOfFlowScreen extends PureComponent {
}
async _onOnboardingComplete() {
const { setCompletedOnboarding } = this.props;
const { setCompletedOnboarding, setOnBoardedInThisUISession } = this.props;
setOnBoardedInThisUISession(true);
await setCompletedOnboarding();
}

View File

@ -2,6 +2,7 @@ import { connect } from 'react-redux';
import { getOnboardingInitiator } from '../../../selectors';
import { setCompletedOnboarding } from '../../../store/actions';
import { setOnBoardedInThisUISession } from '../../../ducks/app/app';
import EndOfFlow from './end-of-flow.component';
const mapStateToProps = (state) => {
@ -13,6 +14,8 @@ const mapStateToProps = (state) => {
const mapDispatchToProps = (dispatch) => {
return {
setCompletedOnboarding: () => dispatch(setCompletedOnboarding()),
setOnBoardedInThisUISession: (value) =>
dispatch(setOnBoardedInThisUISession(value)),
};
};

View File

@ -12,6 +12,7 @@ describe('End of Flow Screen', () => {
push: sinon.stub(),
},
setCompletedOnboarding: sinon.stub().resolves(),
setOnBoardedInThisUISession: sinon.stub(),
};
beforeEach(() => {

View File

@ -153,6 +153,7 @@ export default class Home extends PureComponent {
newCustomNetworkAdded: PropTypes.object,
clearNewCustomNetworkAdded: PropTypes.func,
setRpcTarget: PropTypes.func,
onboardedInThisUISession: PropTypes.bool,
};
state = {
@ -613,6 +614,7 @@ export default class Home extends PureComponent {
firstTimeFlowType,
completedOnboarding,
shouldShowSeedPhraseReminder,
onboardedInThisUISession,
} = this.props;
if (forgottenPassword) {
@ -622,8 +624,8 @@ export default class Home extends PureComponent {
}
const showWhatsNew =
((completedOnboarding && firstTimeFlowType === 'import') ||
!completedOnboarding) &&
completedOnboarding &&
(!onboardedInThisUISession || firstTimeFlowType === 'import') &&
announcementsToShow &&
showWhatsNewPopup &&
!showPortfolioTooltip &&

View File

@ -157,6 +157,7 @@ const mapStateToProps = (state) => {
newCollectibleAddedMessage: getNewCollectibleAddedMessage(state),
newTokensImported: getNewTokensImported(state),
newCustomNetworkAdded: appState.newCustomNetworkAdded,
onboardedInThisUISession: appState.onboardedInThisUISession,
};
};

View File

@ -74,6 +74,7 @@ export const UPDATE_PREFERENCES = 'UPDATE_PREFERENCES';
// Onboarding
export const COMPLETE_ONBOARDING = 'COMPLETE_ONBOARDING';
export const ONBOARDED_IN_THIS_UI_SESSION = 'ONBOARDED_IN_THIS_UI_SESSION';
export const SET_MOUSE_USER_STATE = 'SET_MOUSE_USER_STATE';