Bytom Desktop Electron App
修订版 | 5350882b73210cda2352f4cfe46c9075290a2c4f (tree) |
---|---|
时间 | 2019-07-18 17:22:14 |
作者 | Zhiting Lin <zlin035@uott...> |
Commiter | Zhiting Lin |
netinfo fetch after network init.
@@ -64,6 +64,37 @@ class Container extends React.Component { | ||
64 | 64 | }) |
65 | 65 | this.props.showRoot() |
66 | 66 | }) |
67 | + this.props.fetchAccountItem().then(resp => { | |
68 | + const promise = new Promise((resolve, reject) => { | |
69 | + if (resp.data.length == 0) { | |
70 | + this.props.switchAccount('') | |
71 | + resolve() | |
72 | + }else{ | |
73 | + const aliasArray = resp.data.map(account => account.alias) | |
74 | + if(!aliasArray.includes(this.props.currentAccount) ){ | |
75 | + this.props.setDefaultAccount().then(()=>{ | |
76 | + resolve() | |
77 | + }) | |
78 | + }else{ | |
79 | + resolve() | |
80 | + } | |
81 | + } | |
82 | + }) | |
83 | + | |
84 | + return promise.then(()=>{ | |
85 | + return this.props.fetchKeyItem().then(resp => { | |
86 | + if (resp.data.length == 0) { | |
87 | + this.props.updateAccountInit(false) | |
88 | + }else{ | |
89 | + this.props.updateAccountInit(true) | |
90 | + } | |
91 | + return this.props.fetchInfo().then(() => { | |
92 | + this.redirectRoot(this.props) | |
93 | + }) | |
94 | + }) | |
95 | + }) | |
96 | + }) | |
97 | + | |
67 | 98 | setInterval(() => this.props.fetchInfo(), CORE_POLLING_TIME) |
68 | 99 | } |
69 | 100 | if(arg === 'init'){ |
@@ -75,6 +106,7 @@ class Container extends React.Component { | ||
75 | 106 | this.props.updateMiningState(isMining) |
76 | 107 | }) |
77 | 108 | } |
109 | + | |
78 | 110 | if(this.props.lng === 'zh'){ |
79 | 111 | moment.locale('zh-cn') |
80 | 112 | }else{ |
@@ -82,41 +114,6 @@ class Container extends React.Component { | ||
82 | 114 | } |
83 | 115 | } |
84 | 116 | |
85 | - componentWillMount() { | |
86 | - this.props.fetchAccountItem().then(resp => { | |
87 | - const promise = new Promise((resolve, reject) => { | |
88 | - if (resp.data.length == 0) { | |
89 | - this.props.switchAccount('') | |
90 | - resolve() | |
91 | - }else{ | |
92 | - const aliasArray = resp.data.map(account => account.alias) | |
93 | - if(!aliasArray.includes(this.props.currentAccount) ){ | |
94 | - this.props.setDefaultAccount().then(()=>{ | |
95 | - resolve() | |
96 | - }) | |
97 | - }else{ | |
98 | - resolve() | |
99 | - } | |
100 | - } | |
101 | - }) | |
102 | - | |
103 | - return promise.then(()=>{ | |
104 | - return this.props.fetchKeyItem().then(resp => { | |
105 | - if (resp.data.length == 0) { | |
106 | - this.props.updateAccountInit(false) | |
107 | - }else{ | |
108 | - this.props.updateAccountInit(true) | |
109 | - } | |
110 | - return this.props.fetchInfo().then(() => { | |
111 | - this.redirectRoot(this.props) | |
112 | - }) | |
113 | - }) | |
114 | - }) | |
115 | - }) | |
116 | - | |
117 | - setInterval(() => this.props.fetchInfo(), CORE_POLLING_TIME) | |
118 | - } | |
119 | - | |
120 | 117 | componentWillReceiveProps(nextProps) { |
121 | 118 | if (nextProps.accountInit != this.props.accountInit || |
122 | 119 | nextProps.configured != this.props.configured || |