aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkrolxon <krolyxon@tutanota.com>2024-05-10 22:50:44 +0530
committerkrolxon <krolyxon@tutanota.com>2024-05-10 22:50:44 +0530
commit0c8cfe3a9cf727d670550e4ed1ec65b60e6e6e35 (patch)
tree7a8668e7053d6ed9af84ed7699eae7fbd6389f45
parent8a5c7877bde3d4842d2fd1669323d7a9244657bc (diff)
add stats to Connection struct
-rwxr-xr-xsrc/connection.rs9
-rwxr-xr-xsrc/ui.rs2
2 files changed, 10 insertions, 1 deletions
diff --git a/src/connection.rs b/src/connection.rs
index 9fde2e2..d752178 100755
--- a/src/connection.rs
+++ b/src/connection.rs
@@ -19,6 +19,7 @@ pub struct Connection {
pub repeat: bool,
pub random: bool,
pub current_song: Song,
+ pub stats: mpd::Stats,
}
impl Connection {
@@ -43,6 +44,7 @@ impl Connection {
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
.currentsong()
@@ -58,6 +60,7 @@ impl Connection {
repeat,
random,
current_song,
+ stats,
})
}
@@ -81,6 +84,7 @@ impl Connection {
.currentsong()
.unwrap_or_else(|_| Some(empty_song.clone()))
.unwrap_or(empty_song);
+ let stats = self.conn.stats().unwrap_or_default();
// Playback State
match status.state {
@@ -103,7 +107,12 @@ impl Connection {
// Random mode
self.random = status.random;
+ // Current song
self.current_song = current_song;
+
+ //
+
+ self.stats = stats;
}
/// Get progress ratio of current playing song
diff --git a/src/ui.rs b/src/ui.rs
index 1884604..58d3c3c 100755
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -46,7 +46,7 @@ pub fn render(app: &mut App, frame: &mut Frame) {
/// Draws the directory
fn draw_directory_browser(frame: &mut Frame, app: &mut App, size: Rect) {
- let total_songs = app.conn.conn.stats().unwrap().songs.to_string();
+ let total_songs = app.conn.stats.songs.to_string();
let rows = app.browser.filetree.iter().enumerate().map(|(i, (t, s))| {
if t == "file" {