refactor(api): put a SessionApi seam between the commands, the TUI, and the client
Commands and the TUI now hold an Arc<dyn SessionApi> instead of an Arc<Client>. The trait is implemented on Client itself, so the local path is the same client behind one vtable and no wrapper type exists to keep in sync. Daemon mode plugs a remote implementation into the same handle.
This commit is contained in:
@@ -6,6 +6,7 @@ mod rooms;
|
||||
mod search;
|
||||
mod settings;
|
||||
|
||||
use crate::api::SessionApi;
|
||||
use crate::models::AppState;
|
||||
use crate::persist::{
|
||||
snapshot::{Snapshot, restore_messages, restore_searches},
|
||||
@@ -16,11 +17,10 @@ use ratatui::{
|
||||
DefaultTerminal,
|
||||
crossterm::event::{self, Event, KeyEventKind, poll},
|
||||
};
|
||||
use soulseek_rs::Client;
|
||||
use std::{sync::Arc, time::Duration};
|
||||
|
||||
pub struct MainTui {
|
||||
client: Arc<Client>,
|
||||
client: Arc<dyn SessionApi>,
|
||||
state: AppState,
|
||||
download_dir: String,
|
||||
#[allow(dead_code)]
|
||||
@@ -34,7 +34,7 @@ pub struct MainTui {
|
||||
|
||||
impl MainTui {
|
||||
pub fn new(
|
||||
client: Arc<Client>,
|
||||
client: Arc<dyn SessionApi>,
|
||||
download_dir: String,
|
||||
max_concurrent_downloads: usize,
|
||||
search_timeout: Duration,
|
||||
@@ -227,7 +227,7 @@ impl MainTui {
|
||||
|
||||
pub fn launch_main_tui(
|
||||
terminal: DefaultTerminal,
|
||||
client: Arc<Client>,
|
||||
client: Arc<dyn SessionApi>,
|
||||
download_dir: String,
|
||||
max_concurrent_downloads: usize,
|
||||
search_timeout: Duration,
|
||||
|
||||
Reference in New Issue
Block a user