@@ -36,6 +36,7 @@ import { WatchonlySetting } from './components/manage-accounts/watchonlySetting'
36
36
import style from './manage-accounts.module.css' ;
37
37
38
38
interface ManageAccountsProps {
39
+ accounts : accountAPI . IAccount [ ] ;
39
40
deviceIDs : string [ ] ;
40
41
hasAccounts : boolean ;
41
42
}
@@ -48,27 +49,17 @@ type TShowTokens = {
48
49
49
50
interface State {
50
51
editErrorMessage ?: string ;
51
- accounts : accountAPI . IAccount [ ] ;
52
52
showTokens : TShowTokens ;
53
53
currentlyEditedAccount ?: accountAPI . IAccount ;
54
54
}
55
55
56
56
class ManageAccounts extends Component < Props , State > {
57
57
public readonly state : State = {
58
58
editErrorMessage : undefined ,
59
- accounts : [ ] ,
60
59
showTokens : { } ,
61
60
currentlyEditedAccount : undefined ,
62
61
} ;
63
62
64
- private fetchAccounts = ( ) => {
65
- return accountAPI . getAccounts ( ) . then ( accounts => this . setState ( { accounts } ) ) ;
66
- } ;
67
-
68
- public componentDidMount ( ) {
69
- this . fetchAccounts ( ) ;
70
- }
71
-
72
63
private renderAccounts = ( accounts : accountAPI . IAccount [ ] ) => {
73
64
const { showTokens } = this . state ;
74
65
const { t } = this . props ;
@@ -155,9 +146,7 @@ class ManageAccounts extends Component<Props, State> {
155
146
156
147
private toggleAccount = ( accountCode : string , active : boolean ) => {
157
148
return backendAPI . setAccountActive ( accountCode , active ) . then ( ( { success, errorMessage } ) => {
158
- if ( success ) {
159
- return this . fetchAccounts ( ) ;
160
- } else if ( errorMessage ) {
149
+ if ( ! success && errorMessage ) {
161
150
alertUser ( errorMessage ) ;
162
151
}
163
152
} ) ;
@@ -166,9 +155,7 @@ class ManageAccounts extends Component<Props, State> {
166
155
// disabling for now, we'll either bring this back (if user request it) or remove for good
167
156
// private setWatch = async (accountCode: string, watch: boolean) => {
168
157
// const result = await backendAPI.accountSetWatch(accountCode, watch);
169
- // if (result.success) {
170
- // await this.fetchAccounts();
171
- // } else if (result.errorMessage) {
158
+ // if (!result.success && result.errorMessage) {
172
159
// alertUser(result.errorMessage);
173
160
// }
174
161
// };
@@ -226,17 +213,16 @@ class ManageAccounts extends Component<Props, State> {
226
213
227
214
private toggleToken = ( ethAccountCode : string , tokenCode : string , active : boolean ) => {
228
215
backendAPI . setTokenActive ( ethAccountCode , tokenCode , active ) . then ( ( { success, errorMessage } ) => {
229
- if ( success ) {
230
- this . fetchAccounts ( ) ;
231
- } else if ( errorMessage ) {
216
+ if ( ! success && errorMessage ) {
232
217
alertUser ( errorMessage ) ;
233
218
}
234
219
} ) ;
235
220
} ;
236
221
237
222
private updateAccount = ( event : React . SyntheticEvent ) => {
238
223
event . preventDefault ( ) ;
239
- const { accounts, currentlyEditedAccount } = this . state ;
224
+ const { accounts } = this . props ;
225
+ const { currentlyEditedAccount } = this . state ;
240
226
241
227
if ( ! currentlyEditedAccount ) {
242
228
return ;
@@ -256,7 +242,6 @@ class ManageAccounts extends Component<Props, State> {
256
242
if ( currentlyEditedAccount . active !== account ?. active ) {
257
243
this . toggleAccount ( currentlyEditedAccount . code , currentlyEditedAccount . active ) ;
258
244
}
259
- this . fetchAccounts ( ) ;
260
245
this . setState ( {
261
246
editErrorMessage : undefined ,
262
247
currentlyEditedAccount : undefined ,
@@ -265,8 +250,8 @@ class ManageAccounts extends Component<Props, State> {
265
250
} ;
266
251
267
252
public render ( ) {
268
- const { t, deviceIDs, hasAccounts } = this . props ;
269
- const { accounts , editErrorMessage, currentlyEditedAccount } = this . state ;
253
+ const { t, accounts , deviceIDs, hasAccounts } = this . props ;
254
+ const { editErrorMessage, currentlyEditedAccount } = this . state ;
270
255
const accountsByKeystore = getAccountsByKeystore ( accounts ) ;
271
256
return (
272
257
< GuideWrapper >
@@ -358,7 +343,6 @@ class ManageAccounts extends Component<Props, State> {
358
343
</ GuidedContent >
359
344
< AccountGuide />
360
345
</ GuideWrapper >
361
-
362
346
) ;
363
347
}
364
348
}
0 commit comments