Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add liked icon to config and use it over the default
  • Loading branch information
Utagai committed Nov 14, 2020
commit 45450b681f2e24d21800d792f2dc7e098d29e0c3
22 changes: 13 additions & 9 deletions src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ where
song_name += "▶ "
}
if app.liked_song_ids_set.contains(&id) {
song_name += "♥ ";
song_name += app.user_config.liked_icon();
}

song_name += &item.name;
Expand Down Expand Up @@ -423,7 +423,7 @@ where
.map(|item| {
let mut artist = String::new();
if app.followed_artist_ids_set.contains(&item.id.to_owned()) {
artist.push_str("♥ ");
artist.push_str(app.user_config.liked_icon());
}
artist.push_str(&item.name.to_owned());
artist
Expand Down Expand Up @@ -457,7 +457,7 @@ where
let mut album_artist = String::new();
if let Some(album_id) = &item.id {
if app.saved_album_ids_set.contains(&album_id.to_owned()) {
album_artist.push_str("♥ ");
album_artist.push_str(app.user_config.liked_icon());
}
}
album_artist.push_str(&format!(
Expand Down Expand Up @@ -925,7 +925,7 @@ where
};

let track_name = if app.liked_song_ids_set.contains(&item_id) {
format!(" {}", name)
format!("{} {}", app.user_config.liked_icon(), name)
} else {
name
};
Expand Down Expand Up @@ -1191,7 +1191,7 @@ where
let mut album_artist = String::new();
if let Some(album_id) = &item.id {
if app.saved_album_ids_set.contains(&album_id.to_owned()) {
album_artist.push_str("♥ ");
album_artist.push_str(app.user_config.liked_icon());
}
}
album_artist.push_str(&format!(
Expand Down Expand Up @@ -1219,7 +1219,7 @@ where
.map(|item| {
let mut artist = String::new();
if app.followed_artist_ids_set.contains(&item.id.to_owned()) {
artist.push_str("♥ ");
artist.push_str(app.user_config.liked_icon());
}
artist.push_str(&item.name.to_owned());
artist
Expand Down Expand Up @@ -1347,7 +1347,11 @@ where
.map(|album_page| TableItem {
id: album_page.album.id.to_owned(),
format: vec![
format!("♥ {}", &album_page.album.name),
format!(
"{} {}",
app.user_config.liked_icon(),
&album_page.album.name
),
create_artist_string(&album_page.album.artists),
album_page.album.release_date.to_owned(),
],
Expand Down Expand Up @@ -1731,10 +1735,10 @@ fn draw_table<B>(
}
}

// Show this if the song is liked
// Show this the liked icon if the song is liked
if let Some(liked_idx) = header.get_index(ColumnId::Liked) {
if app.liked_song_ids_set.contains(item.id.as_str()) {
formatted_row[liked_idx] = " ♥".to_string();
formatted_row[liked_idx] = app.user_config.liked_icon().to_string();
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/user_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ pub struct BehaviorConfigString {
pub tick_rate_milliseconds: Option<u64>,
pub enable_text_emphasis: Option<bool>,
pub show_loading_indicator: Option<bool>,
pub liked_icon: Option<String>,
}

#[derive(Clone)]
Expand All @@ -221,6 +222,7 @@ pub struct BehaviorConfig {
pub tick_rate_milliseconds: u64,
pub enable_text_emphasis: bool,
pub show_loading_indicator: bool,
pub liked_icon: String,
}

#[derive(Default, Clone, Debug, PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -276,6 +278,7 @@ impl UserConfig {
tick_rate_milliseconds: 250,
enable_text_emphasis: true,
show_loading_indicator: true,
liked_icon: "♥".to_string(),
},
path_to_config: None,
}
Expand Down Expand Up @@ -405,6 +408,10 @@ impl UserConfig {
self.behavior.show_loading_indicator = loading_indicator;
}

if let Some(liked_icon) = behavior_config.liked_icon {
self.behavior.liked_icon = liked_icon;
}

Ok(())
}

Expand Down Expand Up @@ -441,6 +448,10 @@ impl UserConfig {
Ok(())
}
}

pub fn liked_icon(&self) -> &str {
&self.behavior.liked_icon
}
}

fn parse_theme_item(theme_item: &str) -> Result<Color> {
Expand Down