Skip to content

Commit 5fe89e2

Browse files
authored
Fix exchange summary (#1611)
* Fix exchange summary * Better loading bar placement * Fix loading coordinators calc
1 parent 2645c9e commit 5fe89e2

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

frontend/src/components/Dialogs/Exchange.tsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext } from 'react';
1+
import React, { useContext, useEffect, useState } from 'react';
22
import { useTranslation } from 'react-i18next';
33

44
import {
@@ -35,10 +35,19 @@ interface Props {
3535
const ExchangeDialog = ({ open = false, onClose }: Props): JSX.Element => {
3636
const { t } = useTranslation();
3737
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]);
3847

3948
return (
4049
<Dialog open={open} onClose={onClose}>
41-
<div style={federation.loading ? {} : { display: 'none' }}>
50+
<div style={loadingInfo ? {} : { display: 'none' }}>
4251
<LinearProgress variant='indeterminate' />
4352
</div>
4453
<DialogContent>

frontend/src/models/Federation.model.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,14 @@ export class Federation {
176176
lifetime_volume: 0,
177177
version: { major: 0, minor: 0, patch: 0 },
178178
};
179+
this.loading = true;
180+
this.exchange.onlineCoordinators = 0;
181+
this.exchange.loadingCoordinators = Object.keys(this.coordinators).length;
179182
this.updateEnabledCoordinators();
180183

181184
for (const coor of Object.values(this.coordinators)) {
182185
coor.loadInfo(() => {
186+
this.exchange.onlineCoordinators = this.exchange.onlineCoordinators + 1;
183187
this.onCoordinatorSaved();
184188
});
185189
}
@@ -202,14 +206,15 @@ export class Federation {
202206
loadBook = async (): Promise<void> => {
203207
if (this.connection !== 'api') return;
204208

205-
this.loading = true;
206209
this.book = {};
207-
this.triggerHook('onFederationUpdate');
210+
this.loading = true;
211+
this.exchange.onlineCoordinators = 0;
208212
this.exchange.loadingCoordinators = Object.keys(this.coordinators).length;
213+
this.triggerHook('onFederationUpdate');
209214
for (const coor of Object.values(this.coordinators)) {
210215
coor.loadBook(() => {
216+
this.exchange.onlineCoordinators = this.exchange.onlineCoordinators + 1;
211217
this.onCoordinatorSaved();
212-
this.triggerHook('onFederationUpdate');
213218
});
214219
}
215220
};

0 commit comments

Comments
 (0)