From df95c2298ca2d98ea398d21ea7cdc7a28d94f9f5 Mon Sep 17 00:00:00 2001 From: Binarybaron Date: Mon, 1 Dec 2025 20:22:47 +0100 Subject: [PATCH] feat(gui): simplify MakerDiscoveryStatus --- .../MakerDiscoveryStatus.tsx | 149 ++++++++---------- swap/src/cli/event_loop.rs | 3 - 2 files changed, 68 insertions(+), 84 deletions(-) diff --git a/src-gui/src/renderer/components/pages/swap/swap/init/deposit_and_choose_offer/MakerDiscoveryStatus.tsx b/src-gui/src/renderer/components/pages/swap/swap/init/deposit_and_choose_offer/MakerDiscoveryStatus.tsx index e94f784f..3fd0c6f2 100644 --- a/src-gui/src/renderer/components/pages/swap/swap/init/deposit_and_choose_offer/MakerDiscoveryStatus.tsx +++ b/src-gui/src/renderer/components/pages/swap/swap/init/deposit_and_choose_offer/MakerDiscoveryStatus.tsx @@ -17,6 +17,7 @@ import { Chip, CircularProgress, Stack, + Tooltip, } from "@mui/material"; import { Info as InfoIcon, Close as CloseIcon } from "@mui/icons-material"; import { useEffect, useState, useMemo } from "react"; @@ -52,99 +53,85 @@ export default function MakerDiscoveryStatus() { } }, [peers]); - const totalPeers = peers.length; - const quotesReceived = peers.filter( - (p) => p.quote === QuoteStatus.Received, - ).length; - const quotesFailed = peers.filter( - (p) => - p.quote === QuoteStatus.Failed || p.quote === QuoteStatus.NotSupported, - ).length; const quotesInflight = peers.filter( (p) => p.quote === QuoteStatus.Inflight, ).length; + const dialsInflight = peers.filter( + (p) => p.connection === ConnectionStatus.Dialing, + ).length; - const isActive = quotesInflight > 0 || totalPeers === 0; - - const totalCompleted = quotesReceived + quotesFailed; - const progressValue = - totalPeers > 0 ? (totalCompleted / totalPeers) * 100 : 0; + const isActive = quotesInflight > 0 || dialsInflight > 0; return ( <> - setDialogOpen(true)} - sx={{ - width: "100%", - mb: 2, - p: 2, - borderColor: isActive ? "success.main" : "divider", - opacity: isActive ? 1 : 0.6, - cursor: "pointer", - transition: "background-color 0.2s", - "&:hover": { - bgcolor: "action.hover", - }, - }} - > - - - + setDialogOpen(true)} + sx={{ + width: "100%", + mb: 2, + p: 2, + borderColor: isActive ? "success.main" : "divider", + opacity: isActive ? 1 : 0.6, + cursor: "pointer", + transition: "background-color 0.2s", + "&:hover": { + bgcolor: "action.hover", + }, + }} + > + + - {isActive - ? "Getting offers..." - : "Waiting a few seconds before refreshing offers"} - + + {isActive + ? quotesInflight > 0 + ? "Getting offers..." + : "Dialing peers..." + : "Waiting a few seconds..."} + - - - - {quotesReceived} online - - - {quotesFailed} offline - + + + + Connected to {peers.length} peers + + + - + - - - + + setDialogOpen(false)} diff --git a/swap/src/cli/event_loop.rs b/swap/src/cli/event_loop.rs index c388c4fc..6963849f 100644 --- a/swap/src/cli/event_loop.rs +++ b/swap/src/cli/event_loop.rs @@ -5,7 +5,6 @@ use crate::monero; use crate::network::cooperative_xmr_redeem_after_punish::{self, Request, Response}; use crate::network::encrypted_signature; use crate::network::quote::BidQuote; -use crate::network::quotes_cached::QuoteStatus; use crate::network::swap_setup::bob::NewSwap; use crate::protocol::bob::swap::has_already_processed_transfer_proof; use crate::protocol::bob::{BobState, State2}; @@ -21,9 +20,7 @@ use std::collections::HashMap; use std::sync::Arc; use std::time::Duration; use swap_core::bitcoin::EncryptedSignature; -use swap_p2p::observe; use swap_p2p::protocols::redial; -use tracing::Instrument; use uuid::Uuid; // Timeout for the execution setup protocol within the event loop.