Krolyxon
Commit f3fb60a

rmptuif3fb60a

fix highlight delay when song deleted from queue

Author
krolxon
Date
2024-05-12 17:17 +0530
Parent
6338417
Commit
f3fb60a1a0fa5156bd0a4569a383224cdbabd961

+8 −8

4 files changed

  1. M src/app.rs +2 −4
  2. M src/connection.rs +1 −2
  3. M src/event/handler.rs +1 −0
  4. M src/main.rs +4 −2
M src/app.rs View
@@ -12,9 +12,8 @@ pub type AppResult<T> = std::result::Result<T, Box<dyn std::error::Error>>;
1212 /// Application
1313 #[derive(Debug)]
1414 pub struct App {
15− /// check if app is running
16− pub running: bool,
17− pub conn: Connection,
15+ pub running: bool, // Check if app is running
16+ pub conn: Connection, // Connection
1817 pub browser: FileBrowser, // Directory browser
1918 pub queue_list: ContentList<Song>, // Stores the current playing queue
2019 pub pl_list: ContentList<String>, // Stores list of playlists
@@ -91,7 +90,6 @@ impl App {
9190 // }
9291 // });
9392 conn.conn.queue().unwrap().into_iter().for_each(|x| {
94− // vec.push(x.title.unwrap());
9593 vec.push(x);
9694 });
9795 }
M src/connection.rs View
@@ -110,8 +110,7 @@ impl Connection {
110110 // Current song
111111 self.current_song = current_song;
112112
113− //
114−
113+ // Stats
115114 self.stats = stats;
116115 }
117116
M src/event/handler.rs View
@@ -173,6 +173,7 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
173173 app.queue_list.index -= 1;
174174 }
175175
176+ app.conn.update_status();
176177 app.update_queue();
177178 }
178179
M src/main.rs View
@@ -12,14 +12,16 @@ pub type Result<T> = core::result::Result<T, Error>;
1212 pub type Error = Box<dyn std::error::Error>;
1313
1414 fn main() -> AppResult<()> {
15+ // Connection
1516 let env_host = env::var("MPD_HOST").unwrap_or_else(|_| "127.0.0.1".to_string());
1617 let env_port = env::var("MPD_PORT").unwrap_or_else(|_| "6600".to_string());
17− let mut app = App::builder(format!("{}:{}", env_host, env_port).as_str())?;
18+ let url = format!("{}:{}", env_host, env_port);
19+ let mut app = App::builder(&url)?;
1820
21+ // UI
1922 let backend = CrosstermBackend::new(io::stderr());
2023 let terminal = Terminal::new(backend)?;
2124 let events = EventHandler::new(1000);
22−
2325 let mut tui = tui::Tui::new(terminal, events);
2426 tui.init()?;
2527