mirror of
https://github.com/RoboSats/robosats.git
synced 2025-07-29 12:11:39 +00:00
Fix exchange summary (#1611)
* Fix exchange summary * Better loading bar placement * Fix loading coordinators calc
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
import React, { useContext } from 'react';
|
import React, { useContext, useEffect, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -35,10 +35,19 @@ interface Props {
|
|||||||
const ExchangeDialog = ({ open = false, onClose }: Props): JSX.Element => {
|
const ExchangeDialog = ({ open = false, onClose }: Props): JSX.Element => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { federation } = useContext(FederationContext);
|
const { federation } = useContext(FederationContext);
|
||||||
|
const [loadingInfo, setLoadingInfo] = useState<boolean>(true);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (open) federation.loadInfo();
|
||||||
|
}, [open]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setLoadingInfo(federation.loading);
|
||||||
|
}, [federation.loading]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onClose={onClose}>
|
<Dialog open={open} onClose={onClose}>
|
||||||
<div style={federation.loading ? {} : { display: 'none' }}>
|
<div style={loadingInfo ? {} : { display: 'none' }}>
|
||||||
<LinearProgress variant='indeterminate' />
|
<LinearProgress variant='indeterminate' />
|
||||||
</div>
|
</div>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
|
@ -176,10 +176,14 @@ export class Federation {
|
|||||||
lifetime_volume: 0,
|
lifetime_volume: 0,
|
||||||
version: { major: 0, minor: 0, patch: 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();
|
this.updateEnabledCoordinators();
|
||||||
|
|
||||||
for (const coor of Object.values(this.coordinators)) {
|
for (const coor of Object.values(this.coordinators)) {
|
||||||
coor.loadInfo(() => {
|
coor.loadInfo(() => {
|
||||||
|
this.exchange.onlineCoordinators = this.exchange.onlineCoordinators + 1;
|
||||||
this.onCoordinatorSaved();
|
this.onCoordinatorSaved();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -202,14 +206,15 @@ export class Federation {
|
|||||||
loadBook = async (): Promise<void> => {
|
loadBook = async (): Promise<void> => {
|
||||||
if (this.connection !== 'api') return;
|
if (this.connection !== 'api') return;
|
||||||
|
|
||||||
this.loading = true;
|
|
||||||
this.book = {};
|
this.book = {};
|
||||||
this.triggerHook('onFederationUpdate');
|
this.loading = true;
|
||||||
|
this.exchange.onlineCoordinators = 0;
|
||||||
this.exchange.loadingCoordinators = Object.keys(this.coordinators).length;
|
this.exchange.loadingCoordinators = Object.keys(this.coordinators).length;
|
||||||
|
this.triggerHook('onFederationUpdate');
|
||||||
for (const coor of Object.values(this.coordinators)) {
|
for (const coor of Object.values(this.coordinators)) {
|
||||||
coor.loadBook(() => {
|
coor.loadBook(() => {
|
||||||
|
this.exchange.onlineCoordinators = this.exchange.onlineCoordinators + 1;
|
||||||
this.onCoordinatorSaved();
|
this.onCoordinatorSaved();
|
||||||
this.triggerHook('onFederationUpdate');
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user