Add rebindable keys, refactor lists

This commit is contained in:
KoffeinFlummi
2019-03-17 03:17:30 +01:00
parent 3d385aff9b
commit 5a85619105
16 changed files with 757 additions and 605 deletions

View File

@@ -1,7 +1,11 @@
use std::fmt;
use std::sync::Arc;
use rspotify::spotify::model::track::FullTrack;
use queue::Queue;
use traits::ListItem;
#[derive(Clone, Deserialize, Serialize)]
pub struct Track {
pub id: String,
@@ -73,3 +77,18 @@ impl fmt::Debug for Track {
)
}
}
impl ListItem for Track {
fn is_playing(&self, queue: Arc<Queue>) -> bool {
let current = queue.get_current();
current.map(|t| t.id == self.id).unwrap_or(false)
}
fn display_left(&self) -> String {
format!("{}", self)
}
fn display_right(&self) -> String {
self.duration_str()
}
}