From f3fb60a1a0fa5156bd0a4569a383224cdbabd961 Mon Sep 17 00:00:00 2001 From: krolxon Date: Sun, 12 May 2024 17:17:57 +0530 Subject: [PATCH] fix highlight delay when song deleted from queue --- src/app.rs | 6 ++---- src/connection.rs | 3 +-- src/event/handler.rs | 1 + src/main.rs | 6 ++++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app.rs b/src/app.rs index f0b51f2..61f9e9e 100755 --- a/src/app.rs +++ b/src/app.rs @@ -12,9 +12,8 @@ pub type AppResult = std::result::Result>; /// Application #[derive(Debug)] pub struct App { - /// check if app is running - pub running: bool, - pub conn: Connection, + pub running: bool, // Check if app is running + pub conn: Connection, // Connection pub browser: FileBrowser, // Directory browser pub queue_list: ContentList, // Stores the current playing queue pub pl_list: ContentList, // Stores list of playlists @@ -91,7 +90,6 @@ impl App { // } // }); conn.conn.queue().unwrap().into_iter().for_each(|x| { - // vec.push(x.title.unwrap()); vec.push(x); }); } diff --git a/src/connection.rs b/src/connection.rs index d752178..bbe14f6 100755 --- a/src/connection.rs +++ b/src/connection.rs @@ -110,8 +110,7 @@ impl Connection { // Current song self.current_song = current_song; - // - + // Stats self.stats = stats; } diff --git a/src/event/handler.rs b/src/event/handler.rs index 2b2dff3..7bf6448 100755 --- a/src/event/handler.rs +++ b/src/event/handler.rs @@ -173,6 +173,7 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { app.queue_list.index -= 1; } + app.conn.update_status(); app.update_queue(); } diff --git a/src/main.rs b/src/main.rs index d8441d3..3e40ead 100755 --- a/src/main.rs +++ b/src/main.rs @@ -12,14 +12,16 @@ pub type Result = core::result::Result; pub type Error = Box; fn main() -> AppResult<()> { + // Connection let env_host = env::var("MPD_HOST").unwrap_or_else(|_| "127.0.0.1".to_string()); let env_port = env::var("MPD_PORT").unwrap_or_else(|_| "6600".to_string()); - let mut app = App::builder(format!("{}:{}", env_host, env_port).as_str())?; + let url = format!("{}:{}", env_host, env_port); + let mut app = App::builder(&url)?; + // UI let backend = CrosstermBackend::new(io::stderr()); let terminal = Terminal::new(backend)?; let events = EventHandler::new(1000); - let mut tui = tui::Tui::new(terminal, events); tui.init()?;