Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,11 @@ behavior:
tick_rate_milliseconds: 250
# Enable text emphasis (typically italic/bold text styling). Disabling this might be important if the terminal config is otherwise restricted and rendering text escapes interferes with the UI.
enable_text_emphasis: true
# controls whether to show a loading indicator in the top right of the UI whenever communicating with Spotify API
# Controls whether to show a loading indicator in the top right of the UI whenever communicating with Spotify API
show_loading_indicator: true
# Determines the text icon to display next to "liked" Spotify items, such as
# liked songs and albums, or followed artists. Can be any length string.
liked_icon: "♥"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My reservation is here. Technically, in almost all cases this is indeed the "liked icon". However, for artists, one "follows" them, so it kind of breaks there.

I considered some alternative names like "tracked_icon" or similar, but it just didn't feel right. Open to any renaming ideas.


keybindings:
# Key stroke can be used if it only uses two keys:
Expand Down
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.padded_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.padded_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.padded_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.padded_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.padded_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.padded_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.padded_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.padded_liked_icon();
}
}
}
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 padded_liked_icon(&self) -> String {
format!("{} ", &self.behavior.liked_icon)
}
}

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