A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ciphermask/ui/app/select-app.js

47 lines
1.2 KiB

7 years ago
const inherits = require('util').inherits
const Component = require('react').Component
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')
7 years ago
function mapStateToProps (state) {
return {
betaUI: state.metamask.featureFlags.betaUI,
autoAdd: autoAddToBetaUI(state),
isUnlocked: state.metamask.isUnlocked,
}
7 years ago
}
function mapDispatchToProps (dispatch) {
return {
setFeatureFlagToBeta: () => dispatch(setFeatureFlag('betaUI', true)),
}
}
module.exports = connect(mapStateToProps, mapDispatchToProps)(SelectedApp)
7 years ago
inherits(SelectedApp, Component)
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()
}
}
7 years ago
SelectedApp.prototype.render = function () {
const { betaUI } = this.props
const Selected = betaUI ? App : OldApp
return h(Selected)
}