rmptuif3fb60a
fix highlight delay when song deleted from queue
+8 −8
4 files changed
- M src/app.rs +2 −4
- M src/connection.rs +1 −2
- M src/event/handler.rs +1 −0
- M src/main.rs +4 −2
| @@ -12,9 +12,8 @@ pub type AppResult<T> = std::result::Result<T, Box<dyn std::error::Error>>; | |||
| 12 | 12 | /// Application | |
| 13 | 13 | #[derive(Debug)] | |
| 14 | 14 | 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 | |
| 18 | 17 | pub browser: FileBrowser, // Directory browser | |
| 19 | 18 | pub queue_list: ContentList<Song>, // Stores the current playing queue | |
| 20 | 19 | pub pl_list: ContentList<String>, // Stores list of playlists | |
| @@ -91,7 +90,6 @@ impl App { | |||
| 91 | 90 | // } | |
| 92 | 91 | // }); | |
| 93 | 92 | conn.conn.queue().unwrap().into_iter().for_each(|x| { | |
| 94 | − | // vec.push(x.title.unwrap()); | |
| 95 | 93 | vec.push(x); | |
| 96 | 94 | }); | |
| 97 | 95 | } | |
| @@ -110,8 +110,7 @@ impl Connection { | |||
| 110 | 110 | // Current song | |
| 111 | 111 | self.current_song = current_song; | |
| 112 | 112 | ||
| 113 | − | // | |
| 114 | − | ||
| 113 | + | // Stats | |
| 115 | 114 | self.stats = stats; | |
| 116 | 115 | } | |
| 117 | 116 | ||
| @@ -173,6 +173,7 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { | |||
| 173 | 173 | app.queue_list.index -= 1; | |
| 174 | 174 | } | |
| 175 | 175 | ||
| 176 | + | app.conn.update_status(); | |
| 176 | 177 | app.update_queue(); | |
| 177 | 178 | } | |
| 178 | 179 | ||
| @@ -12,14 +12,16 @@ pub type Result<T> = core::result::Result<T, Error>; | |||
| 12 | 12 | pub type Error = Box<dyn std::error::Error>; | |
| 13 | 13 | ||
| 14 | 14 | fn main() -> AppResult<()> { | |
| 15 | + | // Connection | |
| 15 | 16 | let env_host = env::var("MPD_HOST").unwrap_or_else(|_| "127.0.0.1".to_string()); | |
| 16 | 17 | 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)?; | |
| 18 | 20 | ||
| 21 | + | // UI | |
| 19 | 22 | let backend = CrosstermBackend::new(io::stderr()); | |
| 20 | 23 | let terminal = Terminal::new(backend)?; | |
| 21 | 24 | let events = EventHandler::new(1000); | |
| 22 | − | ||
| 23 | 25 | let mut tui = tui::Tui::new(terminal, events); | |
| 24 | 26 | tui.init()?; | |
| 25 | 27 | ||