2017-11-14 17:04:55 +01:00
|
|
|
const inherits = require('util').inherits
|
|
|
|
const Component = require('react').Component
|
2018-03-29 17:00:44 +02:00
|
|
|
const connect = require('react-redux').connect
|
2017-11-14 17:04:55 +01:00
|
|
|
const h = require('react-hyperscript')
|
2018-02-01 03:08:49 +01:00
|
|
|
const { HashRouter } = require('react-router-dom')
|
2017-11-14 17:04:55 +01:00
|
|
|
const App = require('./app')
|
|
|
|
const OldApp = require('../../old-ui/app/app')
|
2018-09-24 17:57:37 +02:00
|
|
|
const { getShouldUseNewUi } = require('./selectors')
|
2018-05-01 01:36:17 +02:00
|
|
|
const { setFeatureFlag } = require('./actions')
|
2018-03-30 00:46:45 +02:00
|
|
|
const I18nProvider = require('./i18n-provider')
|
2017-11-14 17:04:55 +01:00
|
|
|
|
|
|
|
function mapStateToProps (state) {
|
2018-01-15 22:23:44 +01:00
|
|
|
return {
|
|
|
|
isMascara: state.metamask.isMascara,
|
2018-09-24 17:57:37 +02:00
|
|
|
shouldUseNewUi: getShouldUseNewUi(state),
|
2018-01-15 22:23:44 +01:00
|
|
|
}
|
2017-11-14 17:04:55 +01:00
|
|
|
}
|
|
|
|
|
2017-12-07 01:19:45 +01:00
|
|
|
function mapDispatchToProps (dispatch) {
|
|
|
|
return {
|
2017-12-22 19:43:02 +01:00
|
|
|
setFeatureFlagWithModal: () => {
|
|
|
|
return dispatch(setFeatureFlag('betaUI', true, 'BETA_UI_NOTIFICATION_MODAL'))
|
|
|
|
},
|
|
|
|
setFeatureFlagWithoutModal: () => {
|
|
|
|
return dispatch(setFeatureFlag('betaUI', true))
|
|
|
|
},
|
2017-12-07 01:19:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = connect(mapStateToProps, mapDispatchToProps)(SelectedApp)
|
2017-11-14 17:04:55 +01:00
|
|
|
|
|
|
|
inherits(SelectedApp, Component)
|
2017-12-07 01:19:45 +01:00
|
|
|
function SelectedApp () {
|
2018-01-15 22:23:44 +01:00
|
|
|
Component.call(this)
|
2017-12-07 01:19:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SelectedApp.prototype.componentWillReceiveProps = function (nextProps) {
|
2018-01-15 22:23:44 +01:00
|
|
|
// Code commented out until we begin auto adding users to NewUI
|
|
|
|
const {
|
|
|
|
// isUnlocked,
|
|
|
|
// setFeatureFlagWithModal,
|
|
|
|
setFeatureFlagWithoutModal,
|
|
|
|
isMascara,
|
|
|
|
// firstTime,
|
|
|
|
} = this.props
|
|
|
|
|
|
|
|
// if (isMascara || firstTime) {
|
|
|
|
if (isMascara) {
|
|
|
|
setFeatureFlagWithoutModal()
|
|
|
|
}
|
|
|
|
// } else if (!isUnlocked && nextProps.isUnlocked && (nextProps.autoAdd)) {
|
|
|
|
// setFeatureFlagWithModal()
|
|
|
|
// }
|
2017-12-07 01:19:45 +01:00
|
|
|
}
|
2017-11-14 17:04:55 +01:00
|
|
|
|
|
|
|
SelectedApp.prototype.render = function () {
|
2018-09-24 17:57:37 +02:00
|
|
|
const { shouldUseNewUi } = this.props
|
|
|
|
const newUi = h(HashRouter, {
|
|
|
|
hashType: 'noslash',
|
|
|
|
}, [
|
|
|
|
h(I18nProvider, [
|
|
|
|
h(App),
|
|
|
|
]),
|
|
|
|
])
|
|
|
|
return shouldUseNewUi ? newUi : h(OldApp)
|
2017-11-14 17:04:55 +01:00
|
|
|
}
|