aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components
diff options
context:
space:
mode:
Diffstat (limited to 'ui/app/components')
-rw-r--r--ui/app/components/pages/authenticated.js28
-rw-r--r--ui/app/components/pages/initialized.js25
-rw-r--r--ui/app/components/pages/unauthenticated/index.js38
-rw-r--r--ui/app/components/pages/unlock.js (renamed from ui/app/components/pages/unauthenticated/unlock.js)28
4 files changed, 48 insertions, 71 deletions
diff --git a/ui/app/components/pages/authenticated.js b/ui/app/components/pages/authenticated.js
index 89bd238d2..1f6b0be49 100644
--- a/ui/app/components/pages/authenticated.js
+++ b/ui/app/components/pages/authenticated.js
@@ -5,28 +5,20 @@ const h = require('react-hyperscript')
const MetamaskRoute = require('./metamask-route')
const { UNLOCK_ROUTE, INITIALIZE_ROUTE } = require('../../routes')
-const Authenticated = ({ component: Component, isUnlocked, isInitialized, ...props }) => {
- const component = renderProps => {
- switch (true) {
- case isUnlocked:
- return h(Component, { ...renderProps })
- case !isInitialized:
- return h(Redirect, { to: { pathname: INITIALIZE_ROUTE } })
- default:
- return h(Redirect, { to: { pathname: UNLOCK_ROUTE } })
- }
- }
+const Authenticated = props => {
+ const { isUnlocked, isInitialized } = props
- return (
- h(MetamaskRoute, {
- ...props,
- component,
- })
- )
+ switch (true) {
+ case isUnlocked && isInitialized:
+ return h(MetamaskRoute, { ...props })
+ case !isInitialized:
+ return h(Redirect, { to: { pathname: INITIALIZE_ROUTE } })
+ default:
+ return h(Redirect, { to: { pathname: UNLOCK_ROUTE } })
+ }
}
Authenticated.propTypes = {
- component: PropTypes.func,
isUnlocked: PropTypes.bool,
isInitialized: PropTypes.bool,
}
diff --git a/ui/app/components/pages/initialized.js b/ui/app/components/pages/initialized.js
new file mode 100644
index 000000000..3adf67b28
--- /dev/null
+++ b/ui/app/components/pages/initialized.js
@@ -0,0 +1,25 @@
+const { connect } = require('react-redux')
+const PropTypes = require('prop-types')
+const { Redirect } = require('react-router-dom')
+const h = require('react-hyperscript')
+const { INITIALIZE_ROUTE } = require('../../routes')
+const MetamaskRoute = require('./metamask-route')
+
+const Initialized = props => {
+ return props.isInitialized
+ ? h(MetamaskRoute, { ...props })
+ : h(Redirect, { to: { pathname: INITIALIZE_ROUTE } })
+}
+
+Initialized.propTypes = {
+ isInitialized: PropTypes.bool,
+}
+
+const mapStateToProps = state => {
+ const { metamask: { isInitialized } } = state
+ return {
+ isInitialized,
+ }
+}
+
+module.exports = connect(mapStateToProps)(Initialized)
diff --git a/ui/app/components/pages/unauthenticated/index.js b/ui/app/components/pages/unauthenticated/index.js
deleted file mode 100644
index f8b5fa172..000000000
--- a/ui/app/components/pages/unauthenticated/index.js
+++ /dev/null
@@ -1,38 +0,0 @@
-const { connect } = require('react-redux')
-const PropTypes = require('prop-types')
-const { Redirect } = require('react-router-dom')
-const h = require('react-hyperscript')
-const { INITIALIZE_ROUTE } = require('../../../routes')
-const MetamaskRoute = require('../metamask-route')
-
-const Unauthenticated = ({ component: Component, isInitialized, ...props }) => {
- const component = renderProps => {
- return isInitialized
- ? h(Component, { ...renderProps })
- : h(Redirect, { to: { pathname: INITIALIZE_ROUTE } })
- }
-
- return (
- h(MetamaskRoute, {
- ...props,
- component,
- })
- )
-}
-
-Unauthenticated.propTypes = {
- component: PropTypes.func,
- isInitialized: PropTypes.bool,
- isMascara: PropTypes.bool,
- mascaraComponent: PropTypes.func,
-}
-
-const mapStateToProps = state => {
- const { metamask: { isInitialized, isMascara } } = state
- return {
- isInitialized,
- isMascara,
- }
-}
-
-module.exports = connect(mapStateToProps)(Unauthenticated)
diff --git a/ui/app/components/pages/unauthenticated/unlock.js b/ui/app/components/pages/unlock.js
index 72f27c11d..27e093a29 100644
--- a/ui/app/components/pages/unauthenticated/unlock.js
+++ b/ui/app/components/pages/unlock.js
@@ -2,13 +2,13 @@ const { Component } = require('react')
const PropTypes = require('prop-types')
const { connect } = require('react-redux')
const h = require('react-hyperscript')
-const { Redirect, withRouter } = require('react-router-dom')
+const { withRouter } = require('react-router-dom')
const { compose } = require('recompose')
-const { tryUnlockMetamask, forgotPassword } = require('../../../actions')
+const { tryUnlockMetamask, forgotPassword } = require('../../actions')
const getCaretCoordinates = require('textarea-caret')
const EventEmitter = require('events').EventEmitter
-const Mascot = require('../../mascot')
-const { DEFAULT_ROUTE, RESTORE_VAULT_ROUTE } = require('../../../routes')
+const Mascot = require('../mascot')
+const { DEFAULT_ROUTE, RESTORE_VAULT_ROUTE } = require('../../routes')
class UnlockScreen extends Component {
constructor (props) {
@@ -21,6 +21,14 @@ class UnlockScreen extends Component {
this.animationEventEmitter = new EventEmitter()
}
+ componentWillMount () {
+ const { isUnlocked, history } = this.props
+
+ if (isUnlocked) {
+ history.push(DEFAULT_ROUTE)
+ }
+ }
+
componentDidMount () {
const passwordBox = document.getElementById('password-box')
@@ -69,17 +77,7 @@ class UnlockScreen extends Component {
render () {
const { error } = this.state
- const { isUnlocked, history } = this.props
-
- if (isUnlocked) {
- return (
- h(Redirect, {
- to: {
- pathname: DEFAULT_ROUTE,
- },
- })
- )
- }
+ const { history } = this.props
return (
h('.unlock-page.main-container', [