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, fingerprint,
} in peers } in peers
{ {
let item = format!("{:?}: {} ({})", addr, alias, fingerprint); let item = format!("{alias} ({addr:?}) -- {fingerprint}");
let s = Line::from(item.yellow()); let s = Line::from(item.yellow());
let item = ListItem::new(s); let item = ListItem::new(s);
items.push(item); items.push(item);

View file

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