From ce70c867746232da65e66bc483b50e27d956e3ab Mon Sep 17 00:00:00 2001 From: Brad Decker Date: Wed, 16 Dec 2020 09:48:42 -0600 Subject: [PATCH] set last provider when switching to a customRPC (#10084) --- ui/app/components/app/dropdowns/network-dropdown.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ui/app/components/app/dropdowns/network-dropdown.js b/ui/app/components/app/dropdowns/network-dropdown.js index e55f77afc..a2493049d 100644 --- a/ui/app/components/app/dropdowns/network-dropdown.js +++ b/ui/app/components/app/dropdowns/network-dropdown.js @@ -40,6 +40,9 @@ function mapDispatchToProps(dispatch) { setProviderType: (type) => { dispatch(actions.setProviderType(type)) }, + setPreviousProvider: (type) => { + dispatch(actions.setPreviousProvider(type)) + }, setRpcTarget: (target, chainId, ticker, nickname) => { dispatch(actions.setRpcTarget(target, chainId, ticker, nickname)) }, @@ -82,6 +85,7 @@ class NetworkDropdown extends Component { setRpcTarget: PropTypes.func.isRequired, hideNetworkDropdown: PropTypes.func.isRequired, setNetworksTabAddMode: PropTypes.func.isRequired, + setPreviousProvider: PropTypes.func.isRequired, setSelectedSettingsRpcUrl: PropTypes.func.isRequired, frequentRpcListDetail: PropTypes.array.isRequired, networkDropdownOpen: PropTypes.bool.isRequired, @@ -112,6 +116,10 @@ class NetworkDropdown extends Component { } renderCustomRpcList(rpcListDetail, provider) { + const { + provider: { type: providerType }, + setPreviousProvider, + } = this.props const reversedRpcListDetail = rpcListDetail.slice().reverse() return reversedRpcListDetail.map((entry) => { @@ -125,6 +133,7 @@ class NetworkDropdown extends Component { closeMenu={() => this.props.hideNetworkDropdown()} onClick={() => { if (isPrefixedFormattedHexString(chainId)) { + setPreviousProvider(providerType) this.props.setRpcTarget(rpcUrl, chainId, ticker, nickname) } else { this.props.displayInvalidCustomNetworkAlert(nickname || rpcUrl)