better peers formatting

This commit is contained in:
Joe Ardent 2025-08-06 17:11:20 -07:00
parent 29034e09d1
commit c829a4b188
2 changed files with 14 additions and 2 deletions

View file

@ -338,7 +338,7 @@ fn peers(peers: &[Peer], state: &mut ListState, area: Rect, buf: &mut Buffer) {
fingerprint,
} in peers
{
let item = format!("{:?}: {} ({})", addr, alias, fingerprint);
let item = format!("{alias} ({addr:?}) -- {fingerprint}");
let s = Line::from(item.yellow());
let item = ListItem::new(s);
items.push(item);

View file

@ -6,6 +6,7 @@ pub mod transfer;
use std::{
collections::BTreeMap,
fmt::Debug,
net::{Ipv4Addr, SocketAddr, SocketAddrV4},
sync::{Arc, OnceLock},
};
@ -51,13 +52,22 @@ pub enum TransferEvent {
ReceiveRequest { id: Julid, request: ReceiveRequest },
}
#[derive(Clone, Debug)]
#[derive(Clone)]
pub struct ReceiveRequest {
pub alias: String,
pub files: BTreeMap<String, FileMetadata>,
pub tx: UnboundedSender<ReceiveDialog>,
}
impl Debug for ReceiveRequest {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ReceiveRequest")
.field("alias", &self.alias)
.field("files", &self.files)
.finish()
}
}
/// Contains the main network and backend state for an application session.
#[derive(Clone)]
pub struct JocalService {
@ -185,6 +195,7 @@ pub struct Config {
pub multicast_addr: SocketAddrV4,
pub port: u16,
pub download_dir: String,
pub local_ip_addr: SocketAddr,
}
impl Default for Config {
@ -195,6 +206,7 @@ impl Default for Config {
multicast_addr: SocketAddrV4::new(MULTICAST_IP, DEFAULT_PORT),
port: DEFAULT_PORT,
download_dir: dd.to_string_lossy().into(),
local_ip_addr: ([0u8; 4], DEFAULT_PORT).into(),
}
}
}