diff options
author | Alexander Tseung <alextsg@gmail.com> | 2018-04-02 17:59:49 +0800 |
---|---|---|
committer | Alexander Tseung <alextsg@gmail.com> | 2018-04-02 17:59:49 +0800 |
commit | 6277a4c46aa2fd94f0fff047aff346d7f255224d (patch) | |
tree | fa620da6b9143f85080aa18c412db7465965edec /mascara/src/app/first-time/notice-screen.js | |
parent | 2fa554a6414d2231dcd6f2476866ea9c1c7b80ca (diff) | |
download | tangerine-wallet-browser-6277a4c46aa2fd94f0fff047aff346d7f255224d.tar tangerine-wallet-browser-6277a4c46aa2fd94f0fff047aff346d7f255224d.tar.gz tangerine-wallet-browser-6277a4c46aa2fd94f0fff047aff346d7f255224d.tar.bz2 tangerine-wallet-browser-6277a4c46aa2fd94f0fff047aff346d7f255224d.tar.lz tangerine-wallet-browser-6277a4c46aa2fd94f0fff047aff346d7f255224d.tar.xz tangerine-wallet-browser-6277a4c46aa2fd94f0fff047aff346d7f255224d.tar.zst tangerine-wallet-browser-6277a4c46aa2fd94f0fff047aff346d7f255224d.zip |
Refactor onboarding flow
Diffstat (limited to 'mascara/src/app/first-time/notice-screen.js')
-rw-r--r-- | mascara/src/app/first-time/notice-screen.js | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/mascara/src/app/first-time/notice-screen.js b/mascara/src/app/first-time/notice-screen.js index a342f059c..6d45f4353 100644 --- a/mascara/src/app/first-time/notice-screen.js +++ b/mascara/src/app/first-time/notice-screen.js @@ -2,11 +2,17 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import Markdown from 'react-markdown' import { connect } from 'react-redux' +import { withRouter } from 'react-router-dom' +import { compose } from 'recompose' import debounce from 'lodash.debounce' import { markNoticeRead } from '../../../../ui/app/actions' import Identicon from '../../../../ui/app/components/identicon' import Breadcrumbs from './breadcrumbs' -import { DEFAULT_ROUTE } from '../../../../ui/app/routes' +import { + INITIALIZE_ROUTE, + DEFAULT_ROUTE, + INITIALIZE_BACKUP_PHRASE_ROUTE, +} from '../../../../ui/app/routes' import LoadingScreen from './loading-screen' class NoticeScreen extends Component { @@ -25,6 +31,7 @@ class NoticeScreen extends Component { markNoticeRead: PropTypes.func, history: PropTypes.object, isLoading: PropTypes.bool, + noActiveNotices: PropTypes.bool, }; static defaultProps = { @@ -35,14 +42,27 @@ class NoticeScreen extends Component { atBottom: false, } - componentDidMount () { + componentWillMount () { + if (this.props.noActiveNotices) { + console.log('%c NOTICESCREEN NOACTIVENOTICES', 'background: #222; color: #bada55') + this.props.history.push(INITIALIZE_BACKUP_PHRASE_ROUTE) + } + this.onScroll() } acceptTerms = () => { const { markNoticeRead, lastUnreadNotice, history } = this.props markNoticeRead(lastUnreadNotice) - .then(() => history.push(DEFAULT_ROUTE)) + .then(hasActiveNotices => { + console.log('ACCEPT TERMS, NO ACTIVE NOTICES', hasActiveNotices, 'background: #222; color: #bada55') + if (!hasActiveNotices) { + history.push(INITIALIZE_BACKUP_PHRASE_ROUTE) + } else { + this.setState({ atBottom: false }) + this.onScroll() + } + }) } onScroll = debounce(() => { @@ -98,12 +118,24 @@ class NoticeScreen extends Component { } } -export default connect( - ({ metamask: { selectedAddress, lastUnreadNotice }, appState: { isLoading } }) => ({ - lastUnreadNotice, +const mapStateToProps = ({ metamask, appState }) => { + const { selectedAddress, lastUnreadNotice, noActiveNotices } = metamask + const { isLoading } = appState + + return { address: selectedAddress, - }), - dispatch => ({ - markNoticeRead: notice => dispatch(markNoticeRead(notice)), - }) + lastUnreadNotice, + noActiveNotices, + isLoading, + } +} + +export default compose( + withRouter, + connect( + mapStateToProps, + dispatch => ({ + markNoticeRead: notice => dispatch(markNoticeRead(notice)), + }) + ) )(NoticeScreen) |