@@ -78,7 +78,6 @@ export const Account = ({
78
78
const [ usesProxy , setUsesProxy ] = useState < boolean > ( ) ;
79
79
const [ insured , setInsured ] = useState < boolean > ( false ) ;
80
80
const [ uncoveredFunds , setUncoveredFunds ] = useState < string [ ] > ( [ ] ) ;
81
- const [ stateCode , setStateCode ] = useState < string > ( ) ;
82
81
const [ detailID , setDetailID ] = useState < accountApi . ITransaction [ 'internalID' ] | null > ( null ) ;
83
82
const supportedExchanges = useLoad < SupportedExchanges > ( getExchangeSupported ( code ) , [ code ] ) ;
84
83
@@ -217,7 +216,6 @@ export const Account = ({
217
216
} ;
218
217
219
218
useEffect ( ( ) => {
220
- setStateCode ( code ) ;
221
219
setBalance ( undefined ) ;
222
220
setStatus ( undefined ) ;
223
221
setSyncedAddressesCount ( 0 ) ;
@@ -227,24 +225,19 @@ export const Account = ({
227
225
228
226
const hasDataLoaded = balance !== undefined && transactions !== undefined ;
229
227
230
- if ( stateCode !== code ) {
231
- // Sync code property with stateCode to work around a re-render that
232
- // happens briefly before `setStatus(undefined)` stops rendering again below.
233
- return null ;
234
- }
235
- if ( ! account || status === undefined ) {
228
+ if ( ! account ) {
236
229
return null ;
237
230
}
238
231
239
- if ( status . fatalError ) {
232
+ if ( status ? .fatalError ) {
240
233
return (
241
234
< Spinner text = { t ( 'account.fatalError' ) } />
242
235
) ;
243
236
}
244
237
245
238
// Status: offline error
246
239
const offlineErrorTextLines : string [ ] = [ ] ;
247
- if ( status . offlineError !== null ) {
240
+ if ( status !== undefined && status . offlineError !== null ) {
248
241
offlineErrorTextLines . push ( t ( 'account.reconnecting' ) ) ;
249
242
offlineErrorTextLines . push ( status . offlineError ) ;
250
243
if ( usesProxy ) {
@@ -253,7 +246,7 @@ export const Account = ({
253
246
}
254
247
255
248
// Status: not synced
256
- const notSyncedText = ( ! status . synced && syncedAddressesCount !== undefined && syncedAddressesCount > 1 ) ? (
249
+ const notSyncedText = ( status !== undefined && ! status . synced && syncedAddressesCount !== undefined && syncedAddressesCount > 1 ) ? (
257
250
'\n' + t ( 'account.syncedAddressesCount' , {
258
251
count : syncedAddressesCount . toString ( ) ,
259
252
defaultValue : 0 ,
@@ -291,10 +284,10 @@ export const Account = ({
291
284
< Status hidden = { ! hasCard } type = "warning" >
292
285
{ t ( 'warning.sdcard' ) }
293
286
</ Status >
294
- < Status className = { style . status } hidden = { ! status . offlineError } type = "error" >
287
+ < Status className = { style . status } hidden = { status === undefined || ! status . offlineError } type = "error" >
295
288
{ offlineErrorTextLines . join ( '\n' ) }
296
289
</ Status >
297
- < Status className = { style . status } hidden = { status . synced || ! ! status . offlineError } type = "info" >
290
+ < Status className = { style . status } hidden = { status === undefined || status . synced || ! ! status . offlineError } type = "info" >
298
291
{ t ( 'account.initializing' ) }
299
292
{ notSyncedText }
300
293
</ Status >
@@ -319,7 +312,7 @@ export const Account = ({
319
312
</ Link >
320
313
< HideAmountsButton />
321
314
</ Header >
322
- { status . synced && hasDataLoaded && isBitcoinBased ( account . coinCode ) && (
315
+ { status !== undefined && status . synced && hasDataLoaded && isBitcoinBased ( account . coinCode ) && (
323
316
< HeadersSync coinCode = { account . coinCode } />
324
317
) }
325
318
< View >
0 commit comments