chore: formatting

This commit is contained in:
Michel de Graaf
2026-01-04 20:37:03 +01:00
parent 94b33d4bd6
commit dfe6f532fa
22 changed files with 582 additions and 507 deletions
+5 -2
View File
@@ -1,5 +1,5 @@
use std::sync::mpsc::{channel, Receiver, Sender};
use std::sync::Arc;
use std::sync::mpsc::{Receiver, Sender, channel};
use std::time::{Duration, Instant};
use crate::trace;
@@ -161,7 +161,10 @@ impl ActorSystem {
}
}
}
trace!("[actor_system] run_actor_loop ENDED - processed {} messages, {} ticks", message_count, tick_count);
trace!(
"[actor_system] run_actor_loop ENDED - processed {} messages, {} ticks",
message_count, tick_count
);
}
}
+7 -2
View File
@@ -160,7 +160,10 @@ impl PeerActor {
&& let Err(e) =
handle.send(PeerMessage::SendMessage(transfer_response))
{
error!("[peer:{}] Failed to send TransferResponse message: {}", username, e);
error!(
"[peer:{}] Failed to send TransferResponse message: {}",
username, e
);
}
}
PeerMessage::TransferResponse {
@@ -258,7 +261,9 @@ impl PeerActor {
let username = self.peer.read().unwrap().username.clone();
error!(
"[peer:{}] Error reading from peer: {} (kind: {:?}). Disconnecting.",
username, e, e.kind()
username,
e,
e.kind()
);
self.disconnect_with_error(e);
return;
+15 -7
View File
@@ -24,7 +24,7 @@ use std::sync::mpsc::{Receiver, Sender};
use std::sync::{Arc, RwLock};
use std::time::{Duration, Instant};
use crate::{debug, error, info, trace, warn, SoulseekRs};
use crate::{SoulseekRs, debug, error, info, trace, warn};
#[derive(Debug, Clone)]
pub struct PeerAddress {
@@ -483,8 +483,8 @@ impl ServerActor {
obfuscated_port,
} => {
debug!(
"[server] Received GetPeerAddress response for {}: {}:{} (obf_type: {}, obf_port: {})"
, username, host, port, obfuscation_type, obfuscated_port
"[server] Received GetPeerAddress response for {}: {}:{} (obf_type: {}, obf_port: {})",
username, host, port, obfuscation_type, obfuscated_port
);
if let Err(e) = self.client_channel.send(
@@ -496,7 +496,10 @@ impl ServerActor {
obfuscated_port,
},
) {
error!("[server] Error forwarding GetPeerAddress response to client: {}", e);
error!(
"[server] Error forwarding GetPeerAddress response to client: {}",
e
);
}
}
ServerMessage::ProcessRead => {
@@ -515,13 +518,16 @@ impl ServerActor {
let timeout = Duration::from_secs(5);
let context = self.context.clone();
std::thread::spawn(move || loop {
std::thread::spawn(move || {
loop {
if start.elapsed() >= timeout {
let _ = response.send(Err(SoulseekRs::Timeout));
break;
}
if let Some(logged_in) = context.read().unwrap().logged_in {
if let Some(logged_in) =
context.read().unwrap().logged_in
{
let result = if logged_in {
Ok(true)
} else {
@@ -532,6 +538,7 @@ impl ServerActor {
}
std::thread::sleep(Duration::from_millis(100));
}
});
}
ServerMessage::FileSearch { token, query } => {
@@ -560,7 +567,8 @@ impl ServerActor {
Err(e) => {
error!(
"[server] Error reading from server: {} (kind: {:?}). Disconnecting.",
e, e.kind()
e,
e.kind()
);
self.disconnect_with_error(e);
return;
+87 -41
View File
@@ -1,27 +1,27 @@
use crate::actor::server_actor::{PeerAddress, ServerActor, ServerMessage};
use crate::actor::ActorHandle;
use crate::actor::server_actor::{PeerAddress, ServerActor, ServerMessage};
use crate::types::DownloadStatus;
use crate::utils::logger;
use crate::{
actor::{peer_registry::PeerRegistry, ActorSystem},
Transfer,
actor::{ActorSystem, peer_registry::PeerRegistry},
error::{Result, SoulseekRs},
peer::{listen::Listen, ConnectionType, DownloadPeer, NewPeer, Peer},
peer::{ConnectionType, DownloadPeer, NewPeer, Peer, listen::Listen},
types::{Download, Search, SearchResult},
utils::{md5, thread_pool::ThreadPool},
Transfer,
};
use std::{
collections::HashMap,
net::TcpStream,
sync::{
RwLock,
atomic::{AtomicBool, Ordering},
mpsc::{Receiver, Sender},
RwLock,
},
thread::{self, sleep},
};
use std::{
sync::{mpsc, Arc},
sync::{Arc, mpsc},
time::{Duration, Instant},
};
@@ -286,7 +286,8 @@ impl Client {
pub fn remove_peer(&self, username: &str) {
let context = self.context.read().unwrap();
if let Some(ref registry) = context.peer_registry
&& let Some(handle) = registry.remove_peer(username) {
&& let Some(handle) = registry.remove_peer(username)
{
let _ = handle.stop();
}
}
@@ -334,7 +335,8 @@ impl Client {
// Check if cancelled
if let Some(ref flag) = cancel_flag
&& flag.load(Ordering::Relaxed) {
&& flag.load(Ordering::Relaxed)
{
info!("Search cancelled by user");
break;
}
@@ -470,12 +472,14 @@ impl Client {
client_context: Arc<RwLock<ClientContext>>,
own_username: String,
) {
thread::spawn(move || loop {
thread::spawn(move || {
loop {
match reader.recv() {
Ok(operation) => {
match operation {
ClientOperation::ConnectToPeer(peer) => {
let client_context_clone = client_context.clone();
let client_context_clone =
client_context.clone();
let own_username_clone = own_username.clone();
thread::spawn(move || {
@@ -488,8 +492,12 @@ impl Client {
});
}
ClientOperation::SearchResult(search_result) => {
trace!("[client] SearchResult {:?}", search_result);
let mut context = client_context.write().unwrap();
trace!(
"[client] SearchResult {:?}",
search_result
);
let mut context =
client_context.write().unwrap();
let result_token = search_result.token;
// Find the search with matching token
@@ -500,9 +508,13 @@ impl Client {
}
}
}
ClientOperation::PeerDisconnected(username, error) => {
ClientOperation::PeerDisconnected(
username,
error,
) => {
let context = client_context.read().unwrap();
if let Some(ref registry) = context.peer_registry
if let Some(ref registry) =
context.peer_registry
&& let Some(handle) =
registry.remove_peer(&username)
{
@@ -540,17 +552,18 @@ impl Client {
.cloned()
};
let own_username = own_username.clone();
let client_context_clone = client_context.clone();
let client_context_clone =
client_context.clone();
trace!(
"[client] DownloadFromPeer token: {} peer: {:?}",
token,
peer
token, peer
);
match maybe_download {
Some(download) => {
thread::spawn(move || {
let download_peer = DownloadPeer::new(
let download_peer =
DownloadPeer::new(
download.username.clone(),
peer.host.clone(),
peer.port,
@@ -558,33 +571,50 @@ impl Client {
allowed,
own_username,
);
let filename: Option<&str> = download
let filename: Option<&str> =
download
.filename
.split('\\')
.next_back();
match filename {
Some(filename) => {
match download_peer.download_file(
client_context_clone.clone(),
match download_peer
.download_file(
client_context_clone
.clone(),
Some(download.clone()),
None
None,
) {
Ok((download, filename)) => {
Ok((
download,
filename,
)) => {
let _ = download.sender.send(DownloadStatus::Completed);
client_context_clone.write().unwrap().update_download_with_status(download.token, DownloadStatus::Completed);
info!("Successfully downloaded {} bytes to {}", download.size, filename);
info!(
"Successfully downloaded {} bytes to {}",
download.size,
filename
);
}
Err(e) => {
let _ = download.sender.send(DownloadStatus::Failed);
client_context_clone.write().unwrap().update_download_with_status(download.token, DownloadStatus::Failed);
error!(
"Failed to download file '{}' from {}:{} (token: {}) - Error: {}",
filename, peer.host, peer.port, download.token, e
filename,
peer.host,
peer.port,
download.token,
e
);
}
}
}
None => error!("Cant find filename to save download: {:?}", download.filename),
None => error!(
"Cant find filename to save download: {:?}",
download.filename
),
}
});
}
@@ -611,7 +641,10 @@ impl Client {
new_peer.username
);
} else if let Some(server_sender) =
&client_context.read().unwrap().server_sender
&client_context
.read()
.unwrap()
.server_sender
{
server_sender
.send(ServerMessage::GetPeerAddress(
@@ -620,7 +653,8 @@ impl Client {
.unwrap();
}
let addr = new_peer.tcp_stream.peer_addr().unwrap();
let addr =
new_peer.tcp_stream.peer_addr().unwrap();
let host = addr.ip().to_string();
let port: u32 = addr.port().into();
@@ -651,7 +685,11 @@ impl Client {
} => {
debug!(
"Received peer address for {}: {}:{} (obf_type: {}, obf_port: {})",
username, host, port, obfuscation_type, obfuscated_port
username,
host,
port,
obfuscation_type,
obfuscated_port
);
let peer_exists = client_context
@@ -691,7 +729,8 @@ impl Client {
);
let client_context_clone =
client_context.clone();
let own_username_clone = own_username.clone();
let own_username_clone =
own_username.clone();
thread::spawn(move || {
Self::connect_to_peer(
@@ -707,10 +746,13 @@ impl Client {
transfer,
username,
) => {
let mut context = client_context.write().unwrap();
let mut context =
client_context.write().unwrap();
let download_to_update =
context.get_downloads().iter().find_map(|d| {
let download_to_update = context
.get_downloads()
.iter()
.find_map(|d| {
if d.username == username
&& d.filename == transfer.filename
{
@@ -741,7 +783,10 @@ impl Client {
context.remove_download(old_token);
}
}
ClientOperation::UploadFailed(username, filename) => {
ClientOperation::UploadFailed(
username,
filename,
) => {
Self::process_failed_uploads(
client_context.clone(),
&username,
@@ -760,6 +805,7 @@ impl Client {
break;
}
}
}
});
}
@@ -772,7 +818,10 @@ impl Client {
let client_context = client_context.clone();
let peer_clone = peer.clone();
trace!("[client] connecting to {}, with connection_type: {}, and token {:?}", peer.username, peer.connection_type, peer.token);
trace!(
"[client] connecting to {}, with connection_type: {}, and token {:?}",
peer.username, peer.connection_type, peer.token
);
match peer.connection_type {
ConnectionType::P => {
let username = peer.username.clone();
@@ -784,8 +833,7 @@ impl Client {
Err(e) => {
trace!(
"Failed to spawn peer actor for {:?}: {:?}",
username,
e
username, e
);
}
}
@@ -797,8 +845,7 @@ impl Client {
ConnectionType::F => {
trace!(
"[client] downloading from: {}, {:?}",
peer.username,
peer.token
peer.username, peer.token
);
let download_peer = DownloadPeer::new(
peer.username,
@@ -817,8 +864,7 @@ impl Client {
Ok((download, filename)) => {
trace!(
"[client] downloaded {} bytes {:?} ",
filename,
download.size
filename, download.size
);
let _ = download.sender.send(DownloadStatus::Completed);
client_context
+1 -1
View File
@@ -1,4 +1,4 @@
use crate::message::{handlers::Handlers, Message};
use crate::message::{Message, handlers::Handlers};
use std::sync::mpsc::Sender;
use crate::warn;
@@ -1,5 +1,5 @@
use crate::{
message::{server::MessageFactory, Message, MessageHandler},
message::{Message, MessageHandler, server::MessageFactory},
peer::PeerMessage,
};
use std::sync::mpsc::Sender;
@@ -20,9 +20,7 @@ impl MessageHandler<PeerMessage> for PeerInit {
let token = message.read_int32();
trace!(
"PeerInit: username: {}, connection_type: {}, token: {}",
username,
connection_type,
token
username, connection_type, token
);
sender.send(PeerMessage::SetUsername(username)).unwrap();
@@ -2,8 +2,8 @@ use crate::{debug, info};
use std::sync::mpsc::Sender;
use crate::{
actor::server_actor::ServerMessage, message::handlers::MessageHandler,
message::Message,
actor::server_actor::ServerMessage, message::Message,
message::handlers::MessageHandler,
};
pub struct FileSearchHandler;
+10 -13
View File
@@ -195,8 +195,7 @@ impl DownloadPeer {
) -> Result<(), DownloadError> {
trace!(
"[download_peer:{}] performing handshake no_pierce: {}",
self.username,
self.no_pierce
self.username, self.no_pierce
);
if !self.no_pierce {
@@ -231,8 +230,7 @@ impl DownloadPeer {
trace!(
"[download_peer:{}] got token: {} from data chunk",
self.username,
token_u32
self.username, token_u32
);
stream
@@ -277,8 +275,7 @@ impl DownloadPeer {
Ok(0) => {
trace!(
"[download_peer:{}] connection closed by peer. bytes read: {}",
self.username,
processor.total_bytes
self.username, processor.total_bytes
);
break;
}
@@ -294,9 +291,7 @@ impl DownloadPeer {
)?;
trace!(
"[download_peer:{}] got download info for token: {} - filename: {}",
self.username,
self.token,
new_download.filename
self.username, self.token, new_download.filename
);
download = Some(new_download);
processor.received = true;
@@ -307,9 +302,9 @@ impl DownloadPeer {
chunk_counter += 1;
if let Some(ref dl) = download
&& chunk_counter % PROGRESS_UPDATE_CHUNKS == 0 {
let elapsed =
last_update_time.elapsed().as_secs_f64();
&& chunk_counter % PROGRESS_UPDATE_CHUNKS == 0
{
let elapsed = last_update_time.elapsed().as_secs_f64();
let bytes_since_last_update =
PROGRESS_UPDATE_CHUNKS * READ_BUFFER_SIZE;
let speed = if elapsed > 0.0 {
@@ -486,7 +481,9 @@ mod tests {
"file.mp3"
);
assert_eq!(
FileManager::extract_filename_from_path("@@bhfrv\\Soulseek Downloads\\complete\\Beatport Top Deep House (2021)\\michel test file.mp3"),
FileManager::extract_filename_from_path(
"@@bhfrv\\Soulseek Downloads\\complete\\Beatport Top Deep House (2021)\\michel test file.mp3"
),
"michel test file.mp3"
);
assert_eq!(
+13 -8
View File
@@ -9,7 +9,7 @@ use crate::client::{ClientContext, ClientOperation};
use crate::message::{Message, MessageReader};
use crate::peer::{ConnectionType, DownloadPeer, Peer};
use crate::types::Download;
use crate::{debug, error, info, trace, DownloadStatus};
use crate::{DownloadStatus, debug, error, info, trace};
const PEER_INIT_MESSAGE_CODE: u8 = 1;
@@ -79,8 +79,7 @@ fn extract_download_from_buffer(
let token = parse_token_from_buffer(&buffer, username)?;
trace!(
"[listener:{}] got transfer_token: {} from data chunk",
username,
token
username, token
);
let context = client_context.read().unwrap();
@@ -88,7 +87,10 @@ fn extract_download_from_buffer(
if download.is_none() {
let download_tokens = context.get_download_tokens();
trace!("[listener:{peer_ip}:{peer_port}] download token not found: {:?}, download tokens: {:?}", token, download_tokens);
trace!(
"[listener:{peer_ip}:{peer_port}] download token not found: {:?}, download tokens: {:?}",
token, download_tokens
);
}
download
@@ -129,8 +131,7 @@ fn handle_file_connection(
) {
trace!(
"[client] DownloadFromPeer token: {} peer: {:?}",
token,
peer
token, peer
);
let download = extract_download_from_buffer(
@@ -198,7 +199,9 @@ fn handle_incoming_connection(stream: TcpStream, context: ConnectionContext) {
};
let Some(init_data) = parse_peer_init_message(message) else {
error!("[listener:{peer_ip}:{peer_port}] Invalid or unknown peer init message");
error!(
"[listener:{peer_ip}:{peer_port}] Invalid or unknown peer init message"
);
return;
};
@@ -241,7 +244,9 @@ fn handle_incoming_connection(stream: TcpStream, context: ConnectionContext) {
});
}
ConnectionType::D => {
debug!("[listener:{peer_ip}:{peer_port}] connection type is D, not supported yet, closing connection. ");
debug!(
"[listener:{peer_ip}:{peer_port}] connection type is D, not supported yet, closing connection. "
);
}
}
}
+3 -2
View File
@@ -2,8 +2,8 @@ use std::env;
use std::fs::{File, OpenOptions};
use std::io::Write;
use std::sync::{
atomic::{AtomicBool, Ordering},
Mutex, Once,
atomic::{AtomicBool, Ordering},
};
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
@@ -168,7 +168,8 @@ pub fn log(level: LogLevel, message: &str) {
}
// But ALSO write to file if configured (file logging bypasses buffering)
if let Ok(mut log_file) = LOG_FILE.lock()
&& let Some(file) = log_file.as_mut() {
&& let Some(file) = log_file.as_mut()
{
let _ = writeln!(file, "{}", formatted_message_plain);
let _ = file.flush();
}
+1 -2
View File
@@ -467,8 +467,7 @@ fn all_alphanumeric_correct_hash() {
#[test]
fn repeated_numbers_correct_hash() {
let repeated_number_str =
"12345678901234567890123456789012345678901234567890123456789012345678901234567890";
let repeated_number_str = "12345678901234567890123456789012345678901234567890123456789012345678901234567890";
assert_eq!("57edf4a22be3c955ac49da2e2107b67a", md5(repeated_number_str));
}
+4 -2
View File
@@ -1,5 +1,5 @@
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{mpsc, Arc, Mutex};
use std::sync::{Arc, Mutex, mpsc};
use std::thread;
type Job = Box<dyn FnOnce() + Send + 'static>;
@@ -89,7 +89,8 @@ impl Worker {
_active_threads: Arc<AtomicUsize>,
_total_threads: usize,
) -> Worker {
let thread = thread::spawn(move || loop {
let thread = thread::spawn(move || {
loop {
let message = receiver.lock().unwrap().recv();
match message {
Ok(Message::NewJob(job)) => {
@@ -122,6 +123,7 @@ impl Worker {
break;
}
}
}
});
Worker {
+16 -8
View File
@@ -4,16 +4,16 @@ mod models;
mod ui;
use clap::Parser;
use cli::{parse_server_address, Cli, Commands};
use cli::{Cli, Commands, parse_server_address};
use color_eyre::Result;
use config::SearchConfig;
use soulseek_rs::{Client, ClientSettings, PeerAddress};
use std::{
env,
sync::{atomic::AtomicBool, Arc},
sync::{Arc, atomic::AtomicBool},
time::Duration,
};
use ui::{launch_main_tui, show_multi_download_progress, FileSelector};
use ui::{FileSelector, launch_main_tui, show_multi_download_progress};
fn main() -> Result<()> {
color_eyre::install()?;
@@ -33,14 +33,22 @@ fn main() -> Result<()> {
// Set LOG_FILE env var if provided via CLI
if let Some(log_file) = &cli.log_file {
// SAFETY: Called before any threads are spawned
unsafe { env::set_var("LOG_FILE", log_file.to_string_lossy().to_string()) };
unsafe {
env::set_var("LOG_FILE", log_file.to_string_lossy().to_string())
};
}
let username = cli.username
.ok_or_else(|| color_eyre::eyre::eyre!("Username required: use --username or set SOULSEEK_USERNAME env var"))?;
let username = cli.username.ok_or_else(|| {
color_eyre::eyre::eyre!(
"Username required: use --username or set SOULSEEK_USERNAME env var"
)
})?;
let password = cli.password
.ok_or_else(|| color_eyre::eyre::eyre!("Password required: use --password or set SOULSEEK_PASSWORD env var"))?;
let password = cli.password.ok_or_else(|| {
color_eyre::eyre::eyre!(
"Password required: use --password or set SOULSEEK_PASSWORD env var"
)
})?;
let (server_host, server_port) = parse_server_address(&cli.server)?;
+2 -2
View File
@@ -1,8 +1,8 @@
use crate::models::FileDisplayData;
use ratatui::{layout::Rect, widgets::TableState};
use soulseek_rs::{types::Download, DownloadStatus};
use soulseek_rs::{DownloadStatus, types::Download};
use std::sync::atomic::AtomicBool;
use std::sync::{mpsc::Receiver, mpsc::Sender, Arc};
use std::sync::{Arc, mpsc::Receiver, mpsc::Sender};
use std::time::Instant;
#[derive(Debug, Clone, PartialEq)]
+8 -7
View File
@@ -1,27 +1,27 @@
use crate::models::FileDisplayData;
use crate::ui::{
border_style, border_type, format_bytes, format_shortcuts_styled,
get_bitrate, get_spinner_char, header_style, highlight_style,
primary_style, success_style, warning_style, HIGHLIGHT_SYMBOL,
HIGHLIGHT_SYMBOL, border_style, border_type, format_bytes,
format_shortcuts_styled, get_bitrate, get_spinner_char, header_style,
highlight_style, primary_style, success_style, warning_style,
};
use color_eyre::Result;
use ratatui::text::{Line, Span};
use ratatui::{
crossterm::event::{self, poll, Event, KeyCode, KeyEvent, KeyEventKind},
DefaultTerminal, Frame,
crossterm::event::{self, Event, KeyCode, KeyEvent, KeyEventKind, poll},
layout::{Alignment, Constraint, Layout},
style::Style,
widgets::{
Block, Borders, Cell, HighlightSpacing, Paragraph, Row, StatefulWidget,
Table, TableState, Wrap,
},
DefaultTerminal, Frame,
};
use soulseek_rs::Client;
use std::{
collections::HashSet,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
atomic::{AtomicBool, Ordering},
},
time::{Duration, Instant},
};
@@ -114,7 +114,8 @@ impl FileSelector {
};
if poll(timeout)?
&& let Event::Key(key) = event::read()? {
&& let Event::Key(key) = event::read()?
{
self.handle_key(key);
}
}
+12 -11
View File
@@ -1,13 +1,14 @@
use crate::models::DownloadEntry;
use crate::ui::{
border_style, border_type, error_style, format_bytes_progress,
format_progress_bar, format_shortcuts_styled, format_speed, header_style,
highlight_style, inactive_style, primary_style, warning_style,
COLOR_PRIMARY, HIGHLIGHT_SYMBOL,
COLOR_PRIMARY, HIGHLIGHT_SYMBOL, border_style, border_type, error_style,
format_bytes_progress, format_progress_bar, format_shortcuts_styled,
format_speed, header_style, highlight_style, inactive_style, primary_style,
warning_style,
};
use color_eyre::Result;
use ratatui::{
crossterm::event::{self, poll, Event, KeyCode, KeyEvent, KeyEventKind},
DefaultTerminal, Frame,
crossterm::event::{self, Event, KeyCode, KeyEvent, KeyEventKind, poll},
layout::{Alignment, Constraint, Layout},
style::{Modifier, Style},
text::{Line, Span},
@@ -15,11 +16,10 @@ use ratatui::{
Block, Borders, Cell, HighlightSpacing, Paragraph, Row, StatefulWidget,
Table, TableState,
},
DefaultTerminal, Frame,
};
use soulseek_rs::{Client, DownloadStatus};
use std::{
sync::{mpsc, mpsc::Receiver, Arc},
sync::{Arc, mpsc, mpsc::Receiver},
thread,
time::Duration,
};
@@ -82,15 +82,15 @@ impl MultiDownloadProgress {
let mut need_start_next = false;
for download_entry in &mut self.downloads {
if let Some(receiver) = &download_entry.receiver
&& let Ok(status) = receiver.try_recv() {
&& let Ok(status) = receiver.try_recv()
{
let was_active = !download_entry.download.is_finished();
download_entry.download.status = status;
let is_finished = download_entry.download.is_finished();
// If download just finished, decrement active count
if was_active && is_finished {
self.active_count =
self.active_count.saturating_sub(1);
self.active_count = self.active_count.saturating_sub(1);
need_start_next = true;
}
}
@@ -103,7 +103,8 @@ impl MultiDownloadProgress {
// Handle keyboard input
if poll(Duration::from_millis(100))?
&& let Event::Key(key) = event::read()? {
&& let Event::Key(key) = event::read()?
{
self.handle_key(key);
}
+8 -7
View File
@@ -3,28 +3,28 @@ use crate::models::{
SearchStatus,
};
use crate::ui::panes::{
render_downloads_pane, render_results_pane, render_searches_pane,
ResultsPaneParams,
ResultsPaneParams, render_downloads_pane, render_results_pane,
render_searches_pane,
};
use crate::ui::{
border_style, border_type, format_shortcuts_styled, render_download_stats,
};
use color_eyre::Result;
use ratatui::{
DefaultTerminal, Frame,
crossterm::event::{
self, poll, Event, KeyCode, KeyEvent, KeyEventKind, MouseButton,
MouseEvent, MouseEventKind,
self, Event, KeyCode, KeyEvent, KeyEventKind, MouseButton, MouseEvent,
MouseEventKind, poll,
},
layout::{Constraint, Layout},
widgets::{Block, Borders, Paragraph},
DefaultTerminal, Frame,
};
use soulseek_rs::{Client, DownloadStatus};
use std::{
sync::{
Arc,
atomic::AtomicBool,
mpsc::{self},
Arc,
},
thread,
time::{Duration, Instant},
@@ -747,7 +747,8 @@ impl MainTui {
// Update selected search if this is the active one
if let Some(selected_idx) = selected_search_index
&& selected_idx == idx {
&& selected_idx == idx
{
self.state.results_items = search.results.clone();
self.state.results_filtered_items =
search.results.clone();
+4 -4
View File
@@ -1,16 +1,16 @@
use crate::models::DownloadEntry;
use crate::ui::{
border_style, border_type, error_style, format_bytes, format_speed,
header_style, highlight_style, inactive_style, success_style,
warning_style, HIGHLIGHT_SYMBOL,
HIGHLIGHT_SYMBOL, border_style, border_type, error_style, format_bytes,
format_speed, header_style, highlight_style, inactive_style, success_style,
warning_style,
};
use ratatui::{
Frame,
layout::Rect,
widgets::{
Block, Borders, Cell, HighlightSpacing, Paragraph, Row, Table,
TableState,
},
Frame,
};
use soulseek_rs::DownloadStatus;
+1 -1
View File
@@ -3,5 +3,5 @@ mod results_pane;
mod searches_pane;
pub use downloads_pane::render_downloads_pane;
pub use results_pane::{render_results_pane, ResultsPaneParams};
pub use results_pane::{ResultsPaneParams, render_results_pane};
pub use searches_pane::render_searches_pane;
+3 -3
View File
@@ -1,15 +1,15 @@
use crate::models::FileDisplayData;
use crate::ui::{
border_style, border_type, format_bytes, header_style, highlight_style,
HIGHLIGHT_SYMBOL,
HIGHLIGHT_SYMBOL, border_style, border_type, format_bytes, header_style,
highlight_style,
};
use ratatui::{
Frame,
layout::Rect,
widgets::{
Block, Borders, Cell, HighlightSpacing, Paragraph, Row, Table,
TableState,
},
Frame,
};
use std::collections::HashSet;
+3 -3
View File
@@ -1,12 +1,12 @@
use crate::models::{SearchEntry, SearchStatus};
use crate::ui::{
border_style, border_type, header_style, highlight_style, success_style,
warning_style, HIGHLIGHT_SYMBOL,
HIGHLIGHT_SYMBOL, border_style, border_type, header_style, highlight_style,
success_style, warning_style,
};
use ratatui::{
Frame,
layout::Rect,
widgets::{Block, Borders, Cell, HighlightSpacing, Row, Table, TableState},
Frame,
};
pub fn render_searches_pane(