Add a field that indicates album ownership #156

Merged
wojtek merged 3 commits from 47---add-a-field-that-indicates-album-ownership into main 2024-03-07 23:12:41 +01:00
2 changed files with 9 additions and 7 deletions
Showing only changes of commit a9a90f4162 - Show all commits

View File

@ -5,11 +5,9 @@ use std::{
use crate::core::collection::{
merge::{Merge, MergeSorted, WithId},
track::Track,
track::{Track, TrackFormat},
};
use super::track::TrackFormat;
/// An album is a collection of tracks that were released together.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Album {

View File

@ -302,7 +302,6 @@ impl<'a, 'b> AlbumState<'a, 'b> {
.map(|a| Self::display_album_date(&a.date))
.unwrap_or_default(),
album
.filter(|a| a.seq.0 > 0)
.map(|a| Self::display_album_seq(&a.seq))
.unwrap_or_default(),
album
@ -340,7 +339,11 @@ impl<'a, 'b> AlbumState<'a, 'b> {
}
fn display_album_seq(seq: &AlbumSeq) -> String {
if seq.0 > 0 {
format!(" ({})", seq.0)
} else {
String::new()
}
}
fn display_album_status(status: &AlbumStatus) -> &'static str {
@ -495,7 +498,7 @@ impl Ui {
}
fn highlight_style(active: bool) -> Style {
// Do not set foreground colour to not overwrite any list-specific customisation.
// Do not set the fg color here as it will overwrite any list-specific customisation.
if active {
Style::default().bg(COLOR_BG_HL)
} else {
@ -818,7 +821,8 @@ mod tests {
#[test]
fn display_album_seq() {
assert_eq!(AlbumState::display_album_seq(&AlbumSeq::default()), " (0)");
assert_eq!(AlbumState::display_album_seq(&AlbumSeq::default()), "");
assert_eq!(AlbumState::display_album_seq(&AlbumSeq(0)), "");
assert_eq!(AlbumState::display_album_seq(&AlbumSeq(5)), " (5)");
}