Add 'hide_display_names' config option

This commit is contained in:
James Adam
2022-07-08 16:22:23 +01:00
committed by Henrik Friedrichsen
parent 0cb1aa5d96
commit ed10872ca3
4 changed files with 45 additions and 30 deletions

View File

@@ -74,6 +74,7 @@ pub struct ConfigValues {
pub playback_state: Option<PlaybackState>,
pub track_format: Option<TrackFormat>,
pub library_tabs: Option<Vec<LibraryTab>>,
pub hide_display_names: Option<bool>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone)]

View File

@@ -191,10 +191,11 @@ impl ListItem for Playlist {
}
}
fn display_left(&self, _library: Arc<Library>) -> String {
match self.owner_name.as_ref() {
Some(owner) => format!("{}{}", self.name, owner),
None => self.name.clone(),
fn display_left(&self, library: Arc<Library>) -> String {
let hide_owners = library.cfg.values().hide_display_names.unwrap_or(false);
match (self.owner_name.as_ref(), hide_owners) {
(Some(owner), false) => format!("{}{}", self.name, owner),
_ => self.name.clone(),
}
}

View File

@@ -61,7 +61,19 @@ impl LibraryView {
Self {
tabs: tabview,
display_name: library.display_name.clone(),
display_name: {
let hide_username = library
.cfg
.values()
.hide_display_names
.clone()
.unwrap_or(false);
if hide_username {
None
} else {
library.display_name.clone()
}
},
}
}
}