From 21eda0cb6aea0df5722c7d05faee0483bbf4b200 Mon Sep 17 00:00:00 2001 From: HenryNguyen5 Date: Fri, 6 Apr 2018 14:46:54 -0400 Subject: [PATCH] Address PR comments --- .../Header/components/CustomNodeModal.tsx | 3 +-- common/sagas/config/node.ts | 14 +++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/common/components/Header/components/CustomNodeModal.tsx b/common/components/Header/components/CustomNodeModal.tsx index 7b9d421886c..7395b8d648d 100644 --- a/common/components/Header/components/CustomNodeModal.tsx +++ b/common/components/Header/components/CustomNodeModal.tsx @@ -13,7 +13,7 @@ import { } from 'selectors/config'; import { Input, Dropdown } from 'components/ui'; import './CustomNodeModal.scss'; -import { shepherdProvider, shepherd, makeProviderConfig } from 'libs/nodes'; +import { shepherdProvider } from 'libs/nodes'; const CUSTOM = { label: 'Custom', value: 'custom' }; @@ -341,7 +341,6 @@ class CustomNodeModal extends React.Component { private saveAndAdd = () => { const node = this.makeCustomNodeConfigFromState(); - shepherd.useProvider('myccustom', node.id, makeProviderConfig({ network: node.network }), node); if (this.state.network === CUSTOM.value) { const network = this.makeCustomNetworkConfigFromState(); diff --git a/common/sagas/config/node.ts b/common/sagas/config/node.ts index 3efd4d37f3f..5f84755360c 100644 --- a/common/sagas/config/node.ts +++ b/common/sagas/config/node.ts @@ -39,7 +39,8 @@ import { isAutoNode, shepherd, shepherdProvider, - stripWeb3Network + stripWeb3Network, + makeProviderConfig } from 'libs/nodes'; export function* pollOfflineStatus(): SagaIterator { @@ -176,7 +177,14 @@ export function* handleNodeChangeIntent({ } } -export function* switchToNewNode(action: AddCustomNodeAction): SagaIterator { +export function* handleAddCustomNode(action: AddCustomNodeAction): SagaIterator { + const { payload: { config } } = action; + shepherd.useProvider( + 'myccustom', + config.id, + makeProviderConfig({ network: config.network }), + config + ); yield put(changeNodeIntent(action.payload.id)); } @@ -210,5 +218,5 @@ export const node = [ takeEvery(TypeKeys.CONFIG_NODE_CHANGE_FORCE, handleNodeChangeForce), takeLatest(TypeKeys.CONFIG_POLL_OFFLINE_STATUS, handlePollOfflineStatus), takeEvery(TypeKeys.CONFIG_LANGUAGE_CHANGE, reload), - takeEvery(TypeKeys.CONFIG_ADD_CUSTOM_NODE, switchToNewNode) + takeEvery(TypeKeys.CONFIG_ADD_CUSTOM_NODE, handleAddCustomNode) ];