File tree 2 files changed +19
-5
lines changed
2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 1
- import React , { useContext } from 'react' ;
1
+ import React , { useContext , useEffect , useState } from 'react' ;
2
2
import { useTranslation } from 'react-i18next' ;
3
3
4
4
import {
@@ -35,10 +35,19 @@ interface Props {
35
35
const ExchangeDialog = ( { open = false , onClose } : Props ) : JSX . Element => {
36
36
const { t } = useTranslation ( ) ;
37
37
const { federation } = useContext ( FederationContext ) ;
38
+ const [ loadingInfo , setLoadingInfo ] = useState < boolean > ( true ) ;
39
+
40
+ useEffect ( ( ) => {
41
+ if ( open ) federation . loadInfo ( ) ;
42
+ } , [ open ] ) ;
43
+
44
+ useEffect ( ( ) => {
45
+ setLoadingInfo ( federation . loading ) ;
46
+ } , [ federation . loading ] ) ;
38
47
39
48
return (
40
49
< Dialog open = { open } onClose = { onClose } >
41
- < div style = { federation . loading ? { } : { display : 'none' } } >
50
+ < div style = { loadingInfo ? { } : { display : 'none' } } >
42
51
< LinearProgress variant = 'indeterminate' />
43
52
</ div >
44
53
< DialogContent >
Original file line number Diff line number Diff line change @@ -176,10 +176,14 @@ export class Federation {
176
176
lifetime_volume : 0 ,
177
177
version : { major : 0 , minor : 0 , patch : 0 } ,
178
178
} ;
179
+ this . loading = true ;
180
+ this . exchange . onlineCoordinators = 0 ;
181
+ this . exchange . loadingCoordinators = Object . keys ( this . coordinators ) . length ;
179
182
this . updateEnabledCoordinators ( ) ;
180
183
181
184
for ( const coor of Object . values ( this . coordinators ) ) {
182
185
coor . loadInfo ( ( ) => {
186
+ this . exchange . onlineCoordinators = this . exchange . onlineCoordinators + 1 ;
183
187
this . onCoordinatorSaved ( ) ;
184
188
} ) ;
185
189
}
@@ -202,14 +206,15 @@ export class Federation {
202
206
loadBook = async ( ) : Promise < void > => {
203
207
if ( this . connection !== 'api' ) return ;
204
208
205
- this . loading = true ;
206
209
this . book = { } ;
207
- this . triggerHook ( 'onFederationUpdate' ) ;
210
+ this . loading = true ;
211
+ this . exchange . onlineCoordinators = 0 ;
208
212
this . exchange . loadingCoordinators = Object . keys ( this . coordinators ) . length ;
213
+ this . triggerHook ( 'onFederationUpdate' ) ;
209
214
for ( const coor of Object . values ( this . coordinators ) ) {
210
215
coor . loadBook ( ( ) => {
216
+ this . exchange . onlineCoordinators = this . exchange . onlineCoordinators + 1 ;
211
217
this . onCoordinatorSaved ( ) ;
212
- this . triggerHook ( 'onFederationUpdate' ) ;
213
218
} ) ;
214
219
}
215
220
} ;
You can’t perform that action at this time.
0 commit comments