aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/select-app.js
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2017-12-07 08:19:45 +0800
committerDan <danjm.com@gmail.com>2017-12-07 08:19:45 +0800
commitbd5ce9461e5119c13ab8be29db5cdfc57228bac8 (patch)
tree1972f49872559ef55f07ea72e3ce39350e8e8d1f /ui/app/select-app.js
parent9db00fa507c04180f6425cc3b1e3187afa193ab8 (diff)
downloadtangerine-wallet-browser-bd5ce9461e5119c13ab8be29db5cdfc57228bac8.tar
tangerine-wallet-browser-bd5ce9461e5119c13ab8be29db5cdfc57228bac8.tar.gz
tangerine-wallet-browser-bd5ce9461e5119c13ab8be29db5cdfc57228bac8.tar.bz2
tangerine-wallet-browser-bd5ce9461e5119c13ab8be29db5cdfc57228bac8.tar.lz
tangerine-wallet-browser-bd5ce9461e5119c13ab8be29db5cdfc57228bac8.tar.xz
tangerine-wallet-browser-bd5ce9461e5119c13ab8be29db5cdfc57228bac8.tar.zst
tangerine-wallet-browser-bd5ce9461e5119c13ab8be29db5cdfc57228bac8.zip
User is automatically added to new UI if they meet conditions at time of login.
Diffstat (limited to 'ui/app/select-app.js')
-rw-r--r--ui/app/select-app.js32
1 files changed, 29 insertions, 3 deletions
diff --git a/ui/app/select-app.js b/ui/app/select-app.js
index 3cba44052..ffa31b767 100644
--- a/ui/app/select-app.js
+++ b/ui/app/select-app.js
@@ -4,18 +4,44 @@ const connect = require('react-redux').connect
const h = require('react-hyperscript')
const App = require('./app')
const OldApp = require('../../old-ui/app/app')
+const { autoAddToBetaUI } = require('./selectors')
+const { setFeatureFlag } = require('./actions')
function mapStateToProps (state) {
- return { betaUI: state.metamask.featureFlags.betaUI }
+ return {
+ betaUI: state.metamask.featureFlags.betaUI,
+ autoAdd: autoAddToBetaUI(state),
+ isUnlocked: state.metamask.isUnlocked,
+ }
}
-module.exports = connect(mapStateToProps)(SelectedApp)
+function mapDispatchToProps (dispatch) {
+ return {
+ setFeatureFlagToBeta: () => dispatch(setFeatureFlag('betaUI', true)),
+ }
+}
+module.exports = connect(mapStateToProps, mapDispatchToProps)(SelectedApp)
inherits(SelectedApp, Component)
-function SelectedApp () { Component.call(this) }
+function SelectedApp () {
+ this.state = {
+ autoAdd: false,
+ }
+ Component.call(this)
+}
+
+SelectedApp.prototype.componentWillReceiveProps = function (nextProps) {
+ const { isUnlocked, setFeatureFlagToBeta } = this.props
+
+ if (!isUnlocked && nextProps.isUnlocked && nextProps.autoAdd) {
+ this.setState({ autoAdd: nextProps.autoAdd })
+ setFeatureFlagToBeta()
+ }
+}
SelectedApp.prototype.render = function () {
const { betaUI } = this.props
+ const { autoAdd } = this.state
const Selected = betaUI ? App : OldApp
return h(Selected)
}