1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Ensure the seed phrase reminder is displayed with precedence over the network deprecation warning (#15869)

* Ensure the seed phrase reminder is displayed with precedence over the network deprecation message

* Prevent error when attempting to get balance before account info has been fully sete

* Fix implementation of seedphrase-reminder-display-fix

* Prioritize seed phrase reminder notification over portfolio tooltip, and that tooltip over testnet deprecation
This commit is contained in:
Dan J Miller 2022-09-19 15:10:30 -02:30 committed by PeterYinusa
parent e6017ee2a4
commit 1bbeb80dff
5 changed files with 35 additions and 13 deletions

View File

@ -612,6 +612,7 @@ export default class Home extends PureComponent {
showRecoveryPhraseReminder, showRecoveryPhraseReminder,
firstTimeFlowType, firstTimeFlowType,
completedOnboarding, completedOnboarding,
shouldShowSeedPhraseReminder,
} = this.props; } = this.props;
if (forgottenPassword) { if (forgottenPassword) {
@ -658,7 +659,11 @@ export default class Home extends PureComponent {
subHeader={ subHeader={
<Tooltip <Tooltip
position="bottom" position="bottom"
open={!process.env.IN_TEST && showPortfolioTooltip} open={
!process.env.IN_TEST &&
!shouldShowSeedPhraseReminder &&
showPortfolioTooltip
}
interactive interactive
theme="home__subheader-link--tooltip" theme="home__subheader-link--tooltip"
html={ html={

View File

@ -3,7 +3,6 @@ import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom'; import { withRouter } from 'react-router-dom';
import { import {
activeTabHasPermissions, activeTabHasPermissions,
getCurrentEthBalance,
getFirstPermissionRequest, getFirstPermissionRequest,
///: BEGIN:ONLY_INCLUDE_IN(flask) ///: BEGIN:ONLY_INCLUDE_IN(flask)
getFirstSnapUpdateRequest, getFirstSnapUpdateRequest,
@ -24,6 +23,7 @@ import {
getNewCollectibleAddedMessage, getNewCollectibleAddedMessage,
getNewTokensImported, getNewTokensImported,
getShowPortfolioTooltip, getShowPortfolioTooltip,
getShouldShowSeedPhraseReminder,
} from '../../selectors'; } from '../../selectors';
import { import {
@ -72,18 +72,15 @@ const mapStateToProps = (state) => {
const { const {
suggestedAssets, suggestedAssets,
seedPhraseBackedUp, seedPhraseBackedUp,
tokens,
threeBoxSynced, threeBoxSynced,
showRestorePrompt, showRestorePrompt,
selectedAddress, selectedAddress,
connectedStatusPopoverHasBeenShown, connectedStatusPopoverHasBeenShown,
defaultHomeActiveTabName, defaultHomeActiveTabName,
swapsState, swapsState,
dismissSeedBackUpReminder,
firstTimeFlowType, firstTimeFlowType,
completedOnboarding, completedOnboarding,
} = metamask; } = metamask;
const accountBalance = getCurrentEthBalance(state);
const { forgottenPassword, threeBoxLastUpdated } = appState; const { forgottenPassword, threeBoxLastUpdated } = appState;
const totalUnapprovedCount = getTotalUnapprovedCount(state); const totalUnapprovedCount = getTotalUnapprovedCount(state);
const swapsEnabled = getSwapsFeatureIsLive(state); const swapsEnabled = getSwapsFeatureIsLive(state);
@ -123,10 +120,7 @@ const mapStateToProps = (state) => {
suggestedAssets, suggestedAssets,
swapsEnabled, swapsEnabled,
unconfirmedTransactionsCount: unconfirmedTransactionsCountSelector(state), unconfirmedTransactionsCount: unconfirmedTransactionsCountSelector(state),
shouldShowSeedPhraseReminder: shouldShowSeedPhraseReminder: getShouldShowSeedPhraseReminder(state),
seedPhraseBackedUp === false &&
(parseInt(accountBalance, 16) > 0 || tokens.length > 0) &&
dismissSeedBackUpReminder === false,
isPopup, isPopup,
isNotification, isNotification,
threeBoxSynced, threeBoxSynced,

View File

@ -110,6 +110,8 @@ export default class Routes extends Component {
allAccountsOnNetworkAreEmpty: PropTypes.bool, allAccountsOnNetworkAreEmpty: PropTypes.bool,
isTestNet: PropTypes.bool, isTestNet: PropTypes.bool,
currentChainId: PropTypes.string, currentChainId: PropTypes.string,
shouldShowSeedPhraseReminder: PropTypes.bool,
portfolioTooltipIsBeingShown: PropTypes.bool,
}; };
static contextTypes = { static contextTypes = {
@ -368,6 +370,8 @@ export default class Routes extends Component {
allAccountsOnNetworkAreEmpty, allAccountsOnNetworkAreEmpty,
isTestNet, isTestNet,
currentChainId, currentChainId,
shouldShowSeedPhraseReminder,
portfolioTooltipIsBeingShown,
} = this.props; } = this.props;
const loadMessage = const loadMessage =
loadingMessage || isNetworkLoading loadingMessage || isNetworkLoading
@ -383,6 +387,12 @@ export default class Routes extends Component {
const windowType = getEnvironmentType(); const windowType = getEnvironmentType();
const shouldShowNetworkDeprecationWarning =
windowType !== ENVIRONMENT_TYPE_NOTIFICATION &&
isUnlocked &&
!shouldShowSeedPhraseReminder &&
!portfolioTooltipIsBeingShown;
return ( return (
<div <div
className={classnames('app', { className={classnames('app', {
@ -398,9 +408,7 @@ export default class Routes extends Component {
} }
}} }}
> >
{windowType !== ENVIRONMENT_TYPE_NOTIFICATION && isUnlocked && ( {shouldShowNetworkDeprecationWarning && <DeprecatedTestNetworks />}
<DeprecatedTestNetworks />
)}
{shouldShowNetworkInfo && <NewNetworkInfo />} {shouldShowNetworkInfo && <NewNetworkInfo />}
<QRHardwarePopover /> <QRHardwarePopover />
<Modal /> <Modal />

View File

@ -10,6 +10,8 @@ import {
getTheme, getTheme,
getIsTestnet, getIsTestnet,
getCurrentChainId, getCurrentChainId,
getShouldShowSeedPhraseReminder,
getShowPortfolioTooltip,
} from '../../selectors'; } from '../../selectors';
import { import {
lockMetamask, lockMetamask,
@ -48,6 +50,8 @@ function mapStateToProps(state) {
allAccountsOnNetworkAreEmpty: getAllAccountsOnNetworkAreEmpty(state), allAccountsOnNetworkAreEmpty: getAllAccountsOnNetworkAreEmpty(state),
isTestNet: getIsTestnet(state), isTestNet: getIsTestnet(state),
currentChainId: getCurrentChainId(state), currentChainId: getCurrentChainId(state),
shouldShowSeedPhraseReminder: getShouldShowSeedPhraseReminder(state),
portfolioTooltipIsBeingShown: getShowPortfolioTooltip(state),
}; };
} }

View File

@ -442,7 +442,7 @@ export function getTargetAccountWithSendEtherInfo(state, targetAddress) {
} }
export function getCurrentEthBalance(state) { export function getCurrentEthBalance(state) {
return getCurrentAccountWithSendEtherInfo(state).balance; return getCurrentAccountWithSendEtherInfo(state)?.balance;
} }
export function getGasIsLoading(state) { export function getGasIsLoading(state) {
@ -1209,3 +1209,14 @@ export function getAllAccountsOnNetworkAreEmpty(state) {
return hasNoNativeFundsOnAnyAccounts && hasNoTokens; return hasNoNativeFundsOnAnyAccounts && hasNoTokens;
} }
export function getShouldShowSeedPhraseReminder(state) {
const { tokens, seedPhraseBackedUp, dismissSeedBackUpReminder } =
state.metamask;
const accountBalance = getCurrentEthBalance(state) ?? 0;
return (
seedPhraseBackedUp === false &&
(parseInt(accountBalance, 16) > 0 || tokens.length > 0) &&
dismissSeedBackUpReminder === false
);
}