class Container extends React.Component {
constructor(props) {
super(props)
- this.state = {
- noAccountItem: false
- }
this.redirectRoot = this.redirectRoot.bind(this)
}
return
}
- if (accountInit && !this.state.noAccountItem) {
+ if (accountInit) {
if (location.pathname === '/'|| location.pathname.indexOf('initialization') >= 0) {
this.props.showRoot()
}
componentDidMount() {
this.props.fetchAccountItem().then(resp => {
if (resp.data.length == 0) {
- this.setState({noAccountItem: true})
this.props.updateAccountInit(false)
this.redirectRoot(this.props)
+ }else{
+ const aliasArray = resp.data.map(account => account.alias)
+ if(!aliasArray.includes(this.props.currentAccount)){
+ this.props.setDefaultAccount()
+ }
}
})
if(this.props.lng === 'zh'){
nextProps.location.pathname != this.props.location.pathname) {
this.redirectRoot(nextProps)
}
+
}
render() {
return <Loading>{t('main.loading')}</Loading>
} else if (!this.props.configured) {
layout = <Config>{this.props.children}</Config>
- } else if (!this.props.accountInit || this.state.noAccountItem){
+ } else if (!this.props.accountInit){
layout = <Config>{this.props.children}</Config>
} else{
layout = <Main>{this.props.children}</Main>
configKnown: state.core.configKnown,
configured: true,
accountInit: state.core.accountInit,
+ currentAccount: state.core.currentAccount
}),
(dispatch) => ({
fetchInfo: options => dispatch(actions.core.fetchCoreInfo(options)),
showRoot: () => dispatch(actions.app.showRoot),
showInitialization: () => dispatch(actions.app.showInitialization()),
updateAccountInit: (param) => dispatch(actions.app.updateAccountInit(param)),
- fetchAccountItem: () => dispatch(actions.account.fetchItems())
+ fetchAccountItem: () => dispatch(actions.account.fetchItems()),
+ setDefaultAccount:() => dispatch(actions.account.setDefaultAccount())
})
)( withI18n() (Container) )
import { chainClient } from 'utility/environment'
import {push} from 'react-router-redux'
+import uuid from 'uuid'
const registerKey = (data) => {
return (dispatch) => {
if (typeof data.accountAlias == 'string') data.accountAlias = data.accountAlias.trim()
const keyData = {
- 'alias': `${data.accountAlias}Key`,
+ 'alias': `${data.accountAlias}Key-${uuid.v4()}`,
'password': data.password
}
const restoreMnemonic = (data, success) => {
return (dispatch) => {
- if (typeof data.keyAlias == 'string') data.keyAlias = data.keyAlias.trim()
if (typeof data.mnemonic == 'string') data.mnemonic = data.mnemonic.trim()
const keyData = {
- 'alias': data.keyAlias,
+ 'alias': `key-${uuid.v4()}`,
'password': data.password,
'mnemonic': data.mnemonic
}
const t = this.props.t
const {
- fields: {mnemonic, keyAlias, password, confirmPassword},
+ fields: {mnemonic, password, confirmPassword},
error,
handleSubmit,
submitting
title={t('init.mnemonic')}
fieldProps={mnemonic}
/>
- <TextField
- title={t('form.keyAlias')}
- placeholder={t('init.keyPlaceholder')}
- fieldProps={keyAlias}/>
<PasswordField
title={t('init.keyPassword')}
placeholder={t('init.passwordPlaceholder')}
if (!values.mnemonic) {
errors.mnemonic = t('init.mnemonicRequire')
}
- if (!values.keyAlias) {
- errors.keyAlias = t('key.aliasRequired')
- }
if (!values.password) {
errors.password = t('key.passwordRequired')
} else if (values.password.length < 5) {
form: 'restoreMnemonic',
fields: [
'mnemonic',
- 'keyAlias',
'password',
'confirmPassword',
],