@@ -72,10 +72,14 @@ type Props = {
72
72
onCopyAssetItem : Function ,
73
73
} ;
74
74
75
+ type State = {
76
+ isPreloading : boolean ,
77
+ } ;
78
+
75
79
const DATE_FORMAT = 'YYYY-MM-DD' ;
76
80
77
81
@observer
78
- export default class WalletTransactionsList extends Component < Props > {
82
+ export default class WalletTransactionsList extends Component < Props , State > {
79
83
static contextTypes = {
80
84
intl : intlShape . isRequired ,
81
85
} ;
@@ -87,6 +91,26 @@ export default class WalletTransactionsList extends Component<Props> {
87
91
onOpenExternalLink : ( ) => { } ,
88
92
} ;
89
93
94
+ state = {
95
+ isPreloading : true ,
96
+ } ;
97
+
98
+ // We need to track the mounted state in order to avoid calling
99
+ // setState promise handling code after the component was already unmounted:
100
+ // Read more: https://facebook.github.io/react/blog/2015/12/16/ismounted-antipattern.html
101
+ _isMounted = false ;
102
+
103
+ componentDidMount ( ) {
104
+ this . _isMounted = true ;
105
+ setTimeout ( ( ) => {
106
+ if ( this . _isMounted ) this . setState ( { isPreloading : false } ) ;
107
+ } , 0 ) ;
108
+ }
109
+
110
+ componentWillUnmount ( ) {
111
+ this . _isMounted = false ;
112
+ }
113
+
90
114
expandedTransactionIds : Map < string , WalletTransaction > = new Map ( ) ;
91
115
transactionsShowingMetadata : Map < string , WalletTransaction > = new Map ( ) ;
92
116
virtualList : ?VirtualTransactionList ;
@@ -269,6 +293,8 @@ export default class WalletTransactionsList extends Component<Props> {
269
293
} ;
270
294
271
295
render ( ) {
296
+ const { intl } = this . context ;
297
+ const { isPreloading } = this . state ;
272
298
const {
273
299
hasMoreToLoad ,
274
300
isLoadingTransactions ,
@@ -278,8 +304,6 @@ export default class WalletTransactionsList extends Component<Props> {
278
304
transactions ,
279
305
walletId ,
280
306
} = this . props ;
281
-
282
- const { intl } = this . context ;
283
307
const transactionsGroups = this . groupTransactionsByDay ( transactions ) ;
284
308
285
309
const loadingSpinner =
@@ -335,6 +359,13 @@ export default class WalletTransactionsList extends Component<Props> {
335
359
/>
336
360
) ;
337
361
362
+ if ( isPreloading )
363
+ return (
364
+ < div className = { styles . preloadingBlockWrapper } >
365
+ < LoadingSpinner big />
366
+ </ div >
367
+ ) ;
368
+
338
369
return (
339
370
< div className = { styles . component } >
340
371
{ syncingTransactionsSpinner }
0 commit comments