mirror of
https://github.com/RoboSats/robosats.git
synced 2025-09-13 00:56:22 +00:00
Make it dynamic
This commit is contained in:
@ -34,22 +34,14 @@ interface Props {
|
||||
|
||||
const ExchangeDialog = ({ open = false, onClose }: Props): JSX.Element => {
|
||||
const { t } = useTranslation();
|
||||
const { federation, federationUpdatedAt } = useContext(FederationContext);
|
||||
const { federation, coordinatorUpdatedAt, federationUpdatedAt } = useContext(FederationContext);
|
||||
const [loadingProgress, setLoadingProgress] = useState<number>(0);
|
||||
|
||||
useEffect(() => {
|
||||
if (open) federation.updateExchange();
|
||||
}, [open]);
|
||||
|
||||
useEffect(() => {
|
||||
setLoadingProgress(
|
||||
(federation.exchange.onlineCoordinators / federation.exchange.totalCoordinators) * 100,
|
||||
);
|
||||
}, [
|
||||
federationUpdatedAt,
|
||||
federation.exchange.onlineCoordinators,
|
||||
federation.exchange.totalCoordinators,
|
||||
]);
|
||||
const loadedCoordinators =
|
||||
federation.exchange.enabledCoordinators - federation.exchange.loadingCoordinators;
|
||||
setLoadingProgress((loadedCoordinators / federation.exchange.enabledCoordinators) * 100);
|
||||
}, [open, coordinatorUpdatedAt, federationUpdatedAt]);
|
||||
|
||||
return (
|
||||
<Dialog open={open} onClose={onClose}>
|
||||
|
||||
@ -96,6 +96,16 @@ export class Federation {
|
||||
|
||||
update = async (): Promise<void> => {
|
||||
this.loading = true;
|
||||
this.exchange.info = {
|
||||
num_public_buy_orders: 0,
|
||||
num_public_sell_orders: 0,
|
||||
book_liquidity: 0,
|
||||
active_robots_today: 0,
|
||||
last_day_nonkyc_btc_premium: 0,
|
||||
last_day_volume: 0,
|
||||
lifetime_volume: 0,
|
||||
version: { major: 0, minor: 0, patch: 0 },
|
||||
};
|
||||
this.exchange.loadingCoordinators = Object.keys(this.coordinators).length;
|
||||
for (const coor of Object.values(this.coordinators)) {
|
||||
await coor.update(() => {
|
||||
|
||||
Reference in New Issue
Block a user