Rename AlbumStatus to AlbumOwnership
This commit is contained in:
parent
90c381c165
commit
19a3d450c1
@ -138,16 +138,16 @@ pub enum AlbumSecondaryType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The album's ownership status.
|
/// The album's ownership status.
|
||||||
pub enum AlbumStatus {
|
pub enum AlbumOwnership {
|
||||||
None,
|
None,
|
||||||
Owned(TrackFormat),
|
Owned(TrackFormat),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AlbumStatus {
|
impl AlbumOwnership {
|
||||||
pub fn from_tracks(tracks: &[Track]) -> AlbumStatus {
|
pub fn from_tracks(tracks: &[Track]) -> AlbumOwnership {
|
||||||
match tracks.iter().map(|t| t.quality.format).min() {
|
match tracks.iter().map(|t| t.quality.format).min() {
|
||||||
Some(format) => AlbumStatus::Owned(format),
|
Some(format) => AlbumOwnership::Owned(format),
|
||||||
None => AlbumStatus::None,
|
None => AlbumOwnership::None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,8 +165,8 @@ impl Album {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_status(&self) -> AlbumStatus {
|
pub fn get_ownership(&self) -> AlbumOwnership {
|
||||||
AlbumStatus::from_tracks(&self.tracks)
|
AlbumOwnership::from_tracks(&self.tracks)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use musichoard::collection::{
|
use musichoard::collection::{
|
||||||
album::{Album, AlbumStatus},
|
album::{Album, AlbumOwnership},
|
||||||
artist::Artist,
|
artist::Artist,
|
||||||
track::{Track, TrackFormat},
|
track::{Track, TrackFormat},
|
||||||
};
|
};
|
||||||
@ -175,7 +175,7 @@ impl<'a, 'b> AlbumState<'a, 'b> {
|
|||||||
))
|
))
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
album
|
album
|
||||||
.map(|a| UiDisplay::display_album_status(&a.get_status()))
|
.map(|a| UiDisplay::display_album_status(&a.get_ownership()))
|
||||||
.unwrap_or("")
|
.unwrap_or("")
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -188,9 +188,9 @@ impl<'a, 'b> AlbumState<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn to_list_item(album: &Album) -> ListItem {
|
fn to_list_item(album: &Album) -> ListItem {
|
||||||
let line = match album.get_status() {
|
let line = match album.get_ownership() {
|
||||||
AlbumStatus::None => Line::raw(album.meta.id.title.as_str()),
|
AlbumOwnership::None => Line::raw(album.meta.id.title.as_str()),
|
||||||
AlbumStatus::Owned(format) => match format {
|
AlbumOwnership::Owned(format) => match format {
|
||||||
TrackFormat::Mp3 => Line::styled(album.meta.id.title.as_str(), UiColor::FG_WARN),
|
TrackFormat::Mp3 => Line::styled(album.meta.id.title.as_str(), UiColor::FG_WARN),
|
||||||
TrackFormat::Flac => Line::styled(album.meta.id.title.as_str(), UiColor::FG_GOOD),
|
TrackFormat::Flac => Line::styled(album.meta.id.title.as_str(), UiColor::FG_GOOD),
|
||||||
},
|
},
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use musichoard::collection::{
|
use musichoard::collection::{
|
||||||
album::{
|
album::{
|
||||||
AlbumDate, AlbumId, AlbumLibId, AlbumMeta, AlbumPrimaryType, AlbumSecondaryType, AlbumSeq,
|
AlbumDate, AlbumId, AlbumLibId, AlbumMeta, AlbumOwnership, AlbumPrimaryType,
|
||||||
AlbumStatus,
|
AlbumSecondaryType, AlbumSeq,
|
||||||
},
|
},
|
||||||
artist::ArtistMeta,
|
artist::ArtistMeta,
|
||||||
musicbrainz::{IMusicBrainzRef, MbRefOption},
|
musicbrainz::{IMusicBrainzRef, MbRefOption},
|
||||||
@ -101,10 +101,10 @@ impl UiDisplay {
|
|||||||
types.join(", ")
|
types.join(", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn display_album_status(status: &AlbumStatus) -> &'static str {
|
pub fn display_album_status(status: &AlbumOwnership) -> &'static str {
|
||||||
match status {
|
match status {
|
||||||
AlbumStatus::None => "None",
|
AlbumOwnership::None => "None",
|
||||||
AlbumStatus::Owned(format) => match format {
|
AlbumOwnership::Owned(format) => match format {
|
||||||
TrackFormat::Mp3 => "MP3",
|
TrackFormat::Mp3 => "MP3",
|
||||||
TrackFormat::Flac => "FLAC",
|
TrackFormat::Flac => "FLAC",
|
||||||
},
|
},
|
||||||
@ -284,13 +284,16 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn display_album_status() {
|
fn display_album_status() {
|
||||||
assert_eq!(UiDisplay::display_album_status(&AlbumStatus::None), "None");
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
UiDisplay::display_album_status(&AlbumStatus::Owned(TrackFormat::Mp3)),
|
UiDisplay::display_album_status(&AlbumOwnership::None),
|
||||||
|
"None"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
UiDisplay::display_album_status(&AlbumOwnership::Owned(TrackFormat::Mp3)),
|
||||||
"MP3"
|
"MP3"
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
UiDisplay::display_album_status(&AlbumStatus::Owned(TrackFormat::Flac)),
|
UiDisplay::display_album_status(&AlbumOwnership::Owned(TrackFormat::Flac)),
|
||||||
"FLAC"
|
"FLAC"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user