From 58f52b2b8de9efd43896e23ab0ac9972f45bb278 Mon Sep 17 00:00:00 2001 From: Alexander Tseung Date: Wed, 28 Mar 2018 13:21:53 -0700 Subject: Fix merge conflicts. Refactor onboarding flow. --- mascara/src/app/first-time/index.js | 86 +++++++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 23 deletions(-) (limited to 'mascara/src/app/first-time/index.js') diff --git a/mascara/src/app/first-time/index.js b/mascara/src/app/first-time/index.js index b3494dec2..ea56a2f6e 100644 --- a/mascara/src/app/first-time/index.js +++ b/mascara/src/app/first-time/index.js @@ -1,6 +1,8 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import {connect} from 'react-redux' +import { withRouter, Switch, Route, Redirect } from 'react-router-dom' +import { compose } from 'recompose' import CreatePasswordScreen from './create-password-screen' import UniqueImageScreen from './unique-image-screen' import NoticeScreen from './notice-screen' @@ -12,6 +14,13 @@ import { unMarkPasswordForgotten, showModal, } from '../../../../ui/app/actions' +import { + DEFAULT_ROUTE, + WELCOME_ROUTE, + INITIALIZE_ROUTE, + INITIALIZE_IMPORT_ACCOUNT_ROUTE, + INITIALIZE_IMPORT_WITH_SEED_PHRASE_ROUTE, +} from '../../../../ui/app/routes' class FirstTimeFlow extends Component { @@ -20,7 +29,10 @@ class FirstTimeFlow extends Component { seedWords: PropTypes.string, address: PropTypes.string, noActiveNotices: PropTypes.bool, - goToBuyEtherView: PropTypes.func.isRequired, + goToBuyEtherView: PropTypes.func, + isUnlocked: PropTypes.bool, + history: PropTypes.object, + welcomeScreenSeen: PropTypes.bool, }; static defaultProps = { @@ -47,6 +59,14 @@ class FirstTimeFlow extends Component { } } + componentDidMount () { + const { isInitialized, isUnlocked, history } = this.props + + if (isInitialized || isUnlocked) { + history.push(DEFAULT_ROUTE) + } + } + setScreenType (screenType) { this.setState({ screenType }) } @@ -141,34 +161,54 @@ class FirstTimeFlow extends Component { } render () { - return ( -
- {this.renderScreen()} -
- ) + return this.props.welcomeScreenSeen + ? ( +
+ + + + + +
+ ) + : } - } -export default connect( - ({ - metamask: { - isInitialized, - seedWords, - noActiveNotices, - selectedAddress, - forgottenPassword, - } - }) => ({ +const mapStateToProps = ({ metamask }) => { + const { + isInitialized, + seedWords, + noActiveNotices, + selectedAddress, + forgottenPassword, + isMascara, + isUnlocked, + welcomeScreenSeen, + } = metamask + + return { + isMascara, isInitialized, seedWords, noActiveNotices, address: selectedAddress, forgottenPassword, - }), - dispatch => ({ - leaveImportSeedScreenState: () => dispatch(unMarkPasswordForgotten()), - openBuyEtherModal: () => dispatch(showModal({ name: 'DEPOSIT_ETHER'})), - }) -)(FirstTimeFlow) + isUnlocked, + welcomeScreenSeen, + } +} +const mapDispatchToProps = dispatch => ({ + leaveImportSeedScreenState: () => dispatch(unMarkPasswordForgotten()), + openBuyEtherModal: () => dispatch(showModal({ name: 'DEPOSIT_ETHER'})), +}) + +export default compose( + withRouter, + connect(mapStateToProps, mapDispatchToProps) +)(FirstTimeFlow) -- cgit v1.2.3