diff --git a/src/connection.rs b/src/connection.rs index d6958c2..f6f89cd 100755 --- a/src/connection.rs +++ b/src/connection.rs @@ -13,9 +13,6 @@ pub struct Connection { pub state: String, pub elapsed: Duration, pub total_duration: Duration, - pub volume: u8, - pub repeat: bool, - pub random: bool, pub current_song: Song, pub stats: mpd::Stats, pub status: mpd::Status, @@ -34,17 +31,10 @@ impl Connection { ..Default::default() }; - let songs_filenames: Vec = conn - .listall()? - .into_iter() - .map(|x| x.file) - .collect(); + let songs_filenames: Vec = conn.listall()?.into_iter().map(|x| x.file).collect(); let status = conn.status().unwrap(); let (elapsed, total) = status.time.unwrap_or_default(); - let volume: u8 = status.volume as u8; - let repeat = status.repeat; - let random = status.random; let stats = conn.stats().unwrap_or_default(); let current_song = conn @@ -57,9 +47,6 @@ impl Connection { state: "Stopped".to_string(), elapsed, total_duration: total, - volume, - repeat, - random, current_song, stats, status, @@ -84,13 +71,15 @@ impl Connection { /// Update status pub fn update_status(&mut self) { let status = self.conn.status().unwrap(); + let stats = self.conn.stats().unwrap_or_default(); + let empty_song = self.get_song_with_only_filename("No Song playing or in Queue"); + let current_song = self .conn .currentsong() .unwrap_or_else(|_| Some(empty_song.clone())) .unwrap_or(empty_song); - let stats = self.conn.stats().unwrap_or_default(); // Status self.status = status.clone(); @@ -107,15 +96,6 @@ impl Connection { self.elapsed = elapsed; self.total_duration = total; - // Volume - self.volume = status.volume as u8; - - // Repeat mode - self.repeat = status.repeat; - - // Random mode - self.random = status.random; - // Current song self.current_song = current_song; diff --git a/src/ui.rs b/src/ui.rs index 43f7c6d..973d021 100755 --- a/src/ui.rs +++ b/src/ui.rs @@ -126,7 +126,7 @@ fn draw_directory_browser(frame: &mut Frame, app: &mut App, size: Rect) { .alignment(Alignment::Center), ) .title( - Title::from(format!("Volume: {}%", app.conn.volume).green()) + Title::from(format!("Volume: {}%", app.conn.status.volume).green()) .alignment(Alignment::Right), ) .borders(Borders::ALL), @@ -220,7 +220,7 @@ fn draw_queue(frame: &mut Frame, app: &mut App, size: Rect) { format!("({} items)", app.queue_list.list.len()).bold(), )) .title( - Title::from(format!("Volume: {}%", app.conn.volume).green()) + Title::from(format!("Volume: {}%", app.conn.status.volume).green()) .alignment(Alignment::Right), ) .borders(Borders::ALL), @@ -280,17 +280,17 @@ fn draw_progress_bar(frame: &mut Frame, app: &mut App, size: Rect) { // Get the current modes let mut modes_bottom: String = String::new(); // we do this to check if at least one mode is enabled so we can push "[]" - if app.conn.repeat | app.conn.random { + if app.conn.status.repeat | app.conn.status.random { modes_bottom.push('r'); } if !modes_bottom.is_empty() { modes_bottom.clear(); modes_bottom.push('['); - if app.conn.repeat { + if app.conn.status.repeat { modes_bottom.push('r'); } - if app.conn.random { + if app.conn.status.random { modes_bottom.push('z'); } modes_bottom.push(']');