diff options
Diffstat (limited to 'ui/app')
-rw-r--r-- | ui/app/actions.js | 18 | ||||
-rw-r--r-- | ui/app/app.js | 27 | ||||
-rw-r--r-- | ui/app/config.js | 1 | ||||
-rw-r--r-- | ui/app/reducers/metamask.js | 3 |
4 files changed, 42 insertions, 7 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js index 7f972fb37..337f05248 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -670,11 +670,19 @@ function markAccountsFound() { // function setRpcTarget (newRpc) { - log.debug(`background.setRpcTarget`) - background.setRpcTarget(newRpc) - return { - type: actions.SET_RPC_TARGET, - value: newRpc, + return (dispatch) => { + if (global.METAMASK_DEBUG) console.log(`background.setRpcTarget`) + background.setRpcTarget(newRpc) + background.updateFrequentRpcList(newRpc, (frequentRpcList) => { + const value = { + rpcTarget: newRpc, + frequentRpcList, + } + dispatch({ + type: actions.SET_RPC_TARGET, + value, + }) + }) } } diff --git a/ui/app/app.js b/ui/app/app.js index 63fab5db8..d8519def7 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -58,6 +58,7 @@ function mapStateToProps (state) { forgottenPassword: state.appState.forgottenPassword, lastUnreadNotice: state.metamask.lastUnreadNotice, lostAccounts: state.metamask.lostAccounts, + frequentRpcList: state.metamask.frequentRpcList || [], } } @@ -211,6 +212,7 @@ App.prototype.renderAppBar = function () { App.prototype.renderNetworkDropdown = function () { const props = this.props + const rpcList = props.frequentRpcList const state = this.state || {} const isOpen = state.isNetworkMenuOpen @@ -256,12 +258,15 @@ App.prototype.renderNetworkDropdown = function () { h(DropMenuItem, { label: 'Localhost 8545', closeMenu: () => this.setState({ isNetworkMenuOpen: false }), - action: () => props.dispatch(actions.setRpcTarget('http://localhost:8545')), + action: () => { + props.dispatch(actions.setRpcTarget('http://localhost:8545')) + }, icon: h('i.fa.fa-question-circle.fa-lg'), activeNetworkRender: props.provider.rpcTarget, }), this.renderCustomOption(props.provider), + this.renderCommonRpc(rpcList, props.provider), props.isUnlocked && h(DropMenuItem, { label: 'Custom RPC', @@ -510,3 +515,23 @@ App.prototype.renderCustomOption = function (provider) { }) } } + +App.prototype.renderCommonRpc = function (rpcList, provider) { + const { rpcTarget } = provider + const props = this.props + + return rpcList.map((rpc) => { + if ((rpc === 'http://localhost:8545') || (rpc === rpcTarget)) { + return null + } else { + return h(DropMenuItem, { + label: rpc, + closeMenu: () => this.setState({ isNetworkMenuOpen: false }), + action: () => props.dispatch(actions.setRpcTarget(rpc)), + icon: h('i.fa.fa-question-circle.fa-lg'), + activeNetworkRender: rpc, + }) + } + }) + +} diff --git a/ui/app/config.js b/ui/app/config.js index 65b1ed712..00a4cba88 100644 --- a/ui/app/config.js +++ b/ui/app/config.js @@ -5,6 +5,7 @@ const connect = require('react-redux').connect const actions = require('./actions') const currencies = require('./conversion.json').rows const validUrl = require('valid-url') + module.exports = connect(mapStateToProps)(ConfigScreen) function mapStateToProps (state) { diff --git a/ui/app/reducers/metamask.js b/ui/app/reducers/metamask.js index 3875cf6d1..7bf2969e7 100644 --- a/ui/app/reducers/metamask.js +++ b/ui/app/reducers/metamask.js @@ -55,9 +55,10 @@ function reduceMetamask (state, action) { case actions.SET_RPC_TARGET: return extend(metamaskState, { + frequentRpcList: action.value.frequentRpcList, provider: { type: 'rpc', - rpcTarget: action.value, + rpcTarget: action.value.rpcTarget, }, }) |