mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 12:29:06 +01:00
remove the ability to navigate back into the onboarding flow after completing onboarding (#16916)
* fix issue when navigating back into the onboarding flow after completing onboarding * disable navigating back into the onboarding flow * lint * fix test * lint
This commit is contained in:
parent
8d8fcdcf0e
commit
fde7cb5e17
@ -45,6 +45,7 @@ import {
|
||||
VIEW_QUOTE_ROUTE,
|
||||
CONFIRMATION_V_NEXT_ROUTE,
|
||||
ADD_COLLECTIBLE_ROUTE,
|
||||
ONBOARDING_SECURE_YOUR_WALLET_ROUTE,
|
||||
} from '../../helpers/constants/routes';
|
||||
import ZENDESK_URLS from '../../helpers/constants/zendesk-url';
|
||||
import Tooltip from '../../components/ui/tooltip';
|
||||
@ -414,12 +415,13 @@ export default class Home extends PureComponent {
|
||||
descriptionText={t('backupApprovalNotice')}
|
||||
acceptText={t('backupNow')}
|
||||
onAccept={() => {
|
||||
const backUpSRPRoute = process.env.ONBOARDING_V2
|
||||
? `${ONBOARDING_SECURE_YOUR_WALLET_ROUTE}/?isFromReminder=true`
|
||||
: INITIALIZE_BACKUP_SEED_PHRASE_ROUTE;
|
||||
if (isPopup) {
|
||||
global.platform.openExtensionInBrowser(
|
||||
INITIALIZE_BACKUP_SEED_PHRASE_ROUTE,
|
||||
);
|
||||
global.platform.openExtensionInBrowser(backUpSRPRoute);
|
||||
} else {
|
||||
history.push(INITIALIZE_BACKUP_SEED_PHRASE_ROUTE);
|
||||
history.push(backUpSRPRoute);
|
||||
}
|
||||
}}
|
||||
infoText={t('backupApprovalInfo')}
|
||||
|
@ -19,14 +19,12 @@ import {
|
||||
ONBOARDING_PIN_EXTENSION_ROUTE,
|
||||
ONBOARDING_METAMETRICS,
|
||||
} from '../../helpers/constants/routes';
|
||||
import {
|
||||
getCompletedOnboarding,
|
||||
getSeedPhraseBackedUp,
|
||||
} from '../../ducks/metamask/metamask';
|
||||
import { getCompletedOnboarding } from '../../ducks/metamask/metamask';
|
||||
import {
|
||||
createNewVaultAndGetSeedPhrase,
|
||||
unlockAndGetSeedPhrase,
|
||||
createNewVaultAndRestore,
|
||||
verifySeedPhrase,
|
||||
} from '../../store/actions';
|
||||
import { getFirstTimeFlowTypeRoute } from '../../selectors';
|
||||
import Button from '../../components/ui/button';
|
||||
@ -49,18 +47,29 @@ import MetaMetricsComponent from './metametrics/metametrics';
|
||||
export default function OnboardingFlow() {
|
||||
const [secretRecoveryPhrase, setSecretRecoveryPhrase] = useState('');
|
||||
const dispatch = useDispatch();
|
||||
const currentLocation = useLocation();
|
||||
const { pathName, search } = useLocation();
|
||||
const history = useHistory();
|
||||
const t = useI18nContext();
|
||||
const completedOnboarding = useSelector(getCompletedOnboarding);
|
||||
const seedPhraseBackedUp = useSelector(getSeedPhraseBackedUp);
|
||||
const nextRoute = useSelector(getFirstTimeFlowTypeRoute);
|
||||
|
||||
const isFromReminder = new URLSearchParams(search).get('isFromReminder');
|
||||
useEffect(() => {
|
||||
if (completedOnboarding && seedPhraseBackedUp) {
|
||||
if (completedOnboarding && !isFromReminder) {
|
||||
history.push(DEFAULT_ROUTE);
|
||||
}
|
||||
}, [history, completedOnboarding, seedPhraseBackedUp]);
|
||||
}, [history, completedOnboarding, isFromReminder]);
|
||||
|
||||
useEffect(() => {
|
||||
const verifyAndSetSeedPhrase = async () => {
|
||||
if (completedOnboarding && !secretRecoveryPhrase) {
|
||||
const verifiedSeedPhrase = await verifySeedPhrase();
|
||||
if (verifiedSeedPhrase) {
|
||||
setSecretRecoveryPhrase(verifiedSeedPhrase);
|
||||
}
|
||||
}
|
||||
};
|
||||
verifyAndSetSeedPhrase();
|
||||
}, [completedOnboarding, secretRecoveryPhrase]);
|
||||
|
||||
const handleCreateNewAccount = async (password) => {
|
||||
const newSecretRecoveryPhrase = await dispatch(
|
||||
@ -97,7 +106,6 @@ export default function OnboardingFlow() {
|
||||
)}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={ONBOARDING_SECURE_YOUR_WALLET_ROUTE}
|
||||
component={SecureYourWallet}
|
||||
/>
|
||||
@ -170,7 +178,7 @@ export default function OnboardingFlow() {
|
||||
<Route exact path="*" component={OnboardingFlowSwitch} />
|
||||
</Switch>
|
||||
</div>
|
||||
{currentLocation?.pathname === ONBOARDING_COMPLETION_ROUTE && (
|
||||
{pathName === ONBOARDING_COMPLETION_ROUTE && (
|
||||
<Button
|
||||
className="onboarding-flow__twitter-button"
|
||||
type="link"
|
||||
|
@ -29,6 +29,7 @@ jest.mock('../../store/actions', () => ({
|
||||
createNewVaultAndGetSeedPhrase: jest.fn().mockResolvedValue(null),
|
||||
unlockAndGetSeedPhrase: jest.fn().mockResolvedValue(null),
|
||||
createNewVaultAndRestore: jest.fn(),
|
||||
verifySeedPhrase: jest.fn(),
|
||||
}));
|
||||
|
||||
describe('Onboarding Flow', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user