diff options
author | Dan <danjm.com@gmail.com> | 2018-06-07 03:10:43 +0800 |
---|---|---|
committer | Dan <danjm.com@gmail.com> | 2018-06-07 03:10:43 +0800 |
commit | ae55e8a3c122a3f6d91e28153124bfb6a13ded84 (patch) | |
tree | b23043409b2877bce4096d411f3c3273a610b146 /ui/app/components/pages/create-account/import-account/json.js | |
parent | aee9247faab984734d2f0278baaf768e2a7926d2 (diff) | |
parent | 1fb408f62eb081311937420bb42da6c835510590 (diff) | |
download | tangerine-wallet-browser-ae55e8a3c122a3f6d91e28153124bfb6a13ded84.tar.gz tangerine-wallet-browser-ae55e8a3c122a3f6d91e28153124bfb6a13ded84.tar.zst tangerine-wallet-browser-ae55e8a3c122a3f6d91e28153124bfb6a13ded84.zip |
Merge branch 'develop' into i3725-refactor-send-component-
Diffstat (limited to 'ui/app/components/pages/create-account/import-account/json.js')
-rw-r--r-- | ui/app/components/pages/create-account/import-account/json.js | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/ui/app/components/pages/create-account/import-account/json.js b/ui/app/components/pages/create-account/import-account/json.js index 0164417ec..1dc2ba534 100644 --- a/ui/app/components/pages/create-account/import-account/json.js +++ b/ui/app/components/pages/create-account/import-account/json.js @@ -82,18 +82,19 @@ class JsonImportSubview extends Component { } createNewKeychain () { + const { firstAddress, displayWarning, importNewJsonAccount, setSelectedAddress } = this.props const state = this.state if (!state) { const message = this.context.t('validFileImport') - return this.props.displayWarning(message) + return displayWarning(message) } const { fileContents } = state if (!fileContents) { const message = this.context.t('needImportFile') - return this.props.displayWarning(message) + return displayWarning(message) } const passwordInput = document.getElementById('json-password-box') @@ -101,12 +102,19 @@ class JsonImportSubview extends Component { if (!password) { const message = this.context.t('needImportPassword') - return this.props.displayWarning(message) + return displayWarning(message) } - this.props.importNewJsonAccount([ fileContents, password ]) - // JS runtime requires caught rejections but failures are handled by Redux - .catch() + importNewJsonAccount([ fileContents, password ]) + .then(({ selectedAddress }) => { + if (selectedAddress) { + history.push(DEFAULT_ROUTE) + } else { + displayWarning('Error importing account.') + setSelectedAddress(firstAddress) + } + }) + .catch(err => displayWarning(err)) } } @@ -114,14 +122,17 @@ JsonImportSubview.propTypes = { error: PropTypes.string, goHome: PropTypes.func, displayWarning: PropTypes.func, + firstAddress: PropTypes.string, importNewJsonAccount: PropTypes.func, history: PropTypes.object, + setSelectedAddress: PropTypes.func, t: PropTypes.func, } const mapStateToProps = state => { return { error: state.appState.warning, + firstAddress: Object.keys(state.metamask.accounts)[0], } } @@ -130,6 +141,7 @@ const mapDispatchToProps = dispatch => { goHome: () => dispatch(actions.goHome()), displayWarning: warning => dispatch(actions.displayWarning(warning)), importNewJsonAccount: options => dispatch(actions.importNewAccount('JSON File', options)), + setSelectedAddress: (address) => dispatch(actions.setSelectedAddress(address)), } } |