Add rebindable keys, refactor lists
This commit is contained in:
19
src/track.rs
19
src/track.rs
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user