diff options
author | Alexander Tseung <alextsg@users.noreply.github.com> | 2017-12-23 03:40:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-23 03:40:20 +0800 |
commit | 409d1d30e9d836926e5361fb9e4b5b025b66e313 (patch) | |
tree | c7f247d1e973c50697af8b9905d9fd40d4575659 /ui/app/select-app.js | |
parent | b944a63ff89e3c45f7d7e49b2d93a5442cde4462 (diff) | |
parent | 5a58add797fcdbb023678af84a61f1d2bfdafaf1 (diff) | |
download | tangerine-wallet-browser-409d1d30e9d836926e5361fb9e4b5b025b66e313.tar tangerine-wallet-browser-409d1d30e9d836926e5361fb9e4b5b025b66e313.tar.gz tangerine-wallet-browser-409d1d30e9d836926e5361fb9e4b5b025b66e313.tar.bz2 tangerine-wallet-browser-409d1d30e9d836926e5361fb9e4b5b025b66e313.tar.lz tangerine-wallet-browser-409d1d30e9d836926e5361fb9e4b5b025b66e313.tar.xz tangerine-wallet-browser-409d1d30e9d836926e5361fb9e4b5b025b66e313.tar.zst tangerine-wallet-browser-409d1d30e9d836926e5361fb9e4b5b025b66e313.zip |
Merge pull request #2799 from MetaMask/NewUI-flat
Update UAT to version 4.0.5
Diffstat (limited to 'ui/app/select-app.js')
-rw-r--r-- | ui/app/select-app.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/ui/app/select-app.js b/ui/app/select-app.js new file mode 100644 index 000000000..ac6867aeb --- /dev/null +++ b/ui/app/select-app.js @@ -0,0 +1,61 @@ +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, setNetworkEndpoints } = require('./actions') +const { BETA_UI_NETWORK_TYPE } = require('../../app/scripts/config').enums + +function mapStateToProps (state) { + return { + betaUI: state.metamask.featureFlags.betaUI, + autoAdd: autoAddToBetaUI(state), + isUnlocked: state.metamask.isUnlocked, + isMascara: state.metamask.isMascara, + firstTime: Object.keys(state.metamask.identities).length === 0, + } +} + +function mapDispatchToProps (dispatch) { + return { + setFeatureFlagWithModal: () => { + return dispatch(setFeatureFlag('betaUI', true, 'BETA_UI_NOTIFICATION_MODAL')) + .then(() => dispatch(setNetworkEndpoints(BETA_UI_NETWORK_TYPE))) + }, + setFeatureFlagWithoutModal: () => { + return dispatch(setFeatureFlag('betaUI', true)) + .then(() => dispatch(setNetworkEndpoints(BETA_UI_NETWORK_TYPE))) + }, + } +} +module.exports = connect(mapStateToProps, mapDispatchToProps)(SelectedApp) + +inherits(SelectedApp, Component) +function SelectedApp () { + Component.call(this) +} + +SelectedApp.prototype.componentWillReceiveProps = function (nextProps) { + const { + isUnlocked, + setFeatureFlagWithModal, + setFeatureFlagWithoutModal, + isMascara, + firstTime, + } = this.props + + if (isMascara || firstTime) { + setFeatureFlagWithoutModal() + } else if (!isUnlocked && nextProps.isUnlocked && (nextProps.autoAdd)) { + setFeatureFlagWithModal() + } +} + +SelectedApp.prototype.render = function () { + const { betaUI, isMascara, firstTime } = this.props + + const Selected = betaUI || isMascara || firstTime ? App : OldApp + return h(Selected) +} |