fix highlight delay when song deleted from queue

This commit is contained in:
krolxon 2024-05-12 17:17:57 +05:30
parent 6338417002
commit f3fb60a1a0
4 changed files with 8 additions and 8 deletions

View File

@ -12,9 +12,8 @@ pub type AppResult<T> = std::result::Result<T, Box<dyn std::error::Error>>;
/// Application /// Application
#[derive(Debug)] #[derive(Debug)]
pub struct App { pub struct App {
/// check if app is running pub running: bool, // Check if app is running
pub running: bool, pub conn: Connection, // Connection
pub conn: Connection,
pub browser: FileBrowser, // Directory browser pub browser: FileBrowser, // Directory browser
pub queue_list: ContentList<Song>, // Stores the current playing queue pub queue_list: ContentList<Song>, // Stores the current playing queue
pub pl_list: ContentList<String>, // Stores list of playlists pub pl_list: ContentList<String>, // Stores list of playlists
@ -91,7 +90,6 @@ impl App {
// } // }
// }); // });
conn.conn.queue().unwrap().into_iter().for_each(|x| { conn.conn.queue().unwrap().into_iter().for_each(|x| {
// vec.push(x.title.unwrap());
vec.push(x); vec.push(x);
}); });
} }

View File

@ -110,8 +110,7 @@ impl Connection {
// Current song // Current song
self.current_song = current_song; self.current_song = current_song;
// // Stats
self.stats = stats; self.stats = stats;
} }

View File

@ -173,6 +173,7 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
app.queue_list.index -= 1; app.queue_list.index -= 1;
} }
app.conn.update_status();
app.update_queue(); app.update_queue();
} }

View File

@ -12,14 +12,16 @@ pub type Result<T> = core::result::Result<T, Error>;
pub type Error = Box<dyn std::error::Error>; pub type Error = Box<dyn std::error::Error>;
fn main() -> AppResult<()> { fn main() -> AppResult<()> {
// Connection
let env_host = env::var("MPD_HOST").unwrap_or_else(|_| "127.0.0.1".to_string()); 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 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 backend = CrosstermBackend::new(io::stderr());
let terminal = Terminal::new(backend)?; let terminal = Terminal::new(backend)?;
let events = EventHandler::new(1000); let events = EventHandler::new(1000);
let mut tui = tui::Tui::new(terminal, events); let mut tui = tui::Tui::new(terminal, events);
tui.init()?; tui.init()?;