From 5fe89e26f97799881f346015fd1e37ade3ba22ec Mon Sep 17 00:00:00 2001 From: KoalaSat Date: Sun, 24 Nov 2024 07:35:00 +0000 Subject: [PATCH] Fix exchange summary (#1611) * Fix exchange summary * Better loading bar placement * Fix loading coordinators calc --- frontend/src/components/Dialogs/Exchange.tsx | 13 +++++++++++-- frontend/src/models/Federation.model.ts | 11 ++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/Dialogs/Exchange.tsx b/frontend/src/components/Dialogs/Exchange.tsx index 91f8ed5d1..326694651 100644 --- a/frontend/src/components/Dialogs/Exchange.tsx +++ b/frontend/src/components/Dialogs/Exchange.tsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import React, { useContext, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { @@ -35,10 +35,19 @@ interface Props { const ExchangeDialog = ({ open = false, onClose }: Props): JSX.Element => { const { t } = useTranslation(); const { federation } = useContext(FederationContext); + const [loadingInfo, setLoadingInfo] = useState(true); + + useEffect(() => { + if (open) federation.loadInfo(); + }, [open]); + + useEffect(() => { + setLoadingInfo(federation.loading); + }, [federation.loading]); return ( -
+
diff --git a/frontend/src/models/Federation.model.ts b/frontend/src/models/Federation.model.ts index d97083eee..b53826b76 100644 --- a/frontend/src/models/Federation.model.ts +++ b/frontend/src/models/Federation.model.ts @@ -176,10 +176,14 @@ export class Federation { lifetime_volume: 0, version: { major: 0, minor: 0, patch: 0 }, }; + this.loading = true; + this.exchange.onlineCoordinators = 0; + this.exchange.loadingCoordinators = Object.keys(this.coordinators).length; this.updateEnabledCoordinators(); for (const coor of Object.values(this.coordinators)) { coor.loadInfo(() => { + this.exchange.onlineCoordinators = this.exchange.onlineCoordinators + 1; this.onCoordinatorSaved(); }); } @@ -202,14 +206,15 @@ export class Federation { loadBook = async (): Promise => { if (this.connection !== 'api') return; - this.loading = true; this.book = {}; - this.triggerHook('onFederationUpdate'); + this.loading = true; + this.exchange.onlineCoordinators = 0; this.exchange.loadingCoordinators = Object.keys(this.coordinators).length; + this.triggerHook('onFederationUpdate'); for (const coor of Object.values(this.coordinators)) { coor.loadBook(() => { + this.exchange.onlineCoordinators = this.exchange.onlineCoordinators + 1; this.onCoordinatorSaved(); - this.triggerHook('onFederationUpdate'); }); } };