Handle local tracks in playlist
- Show error on deletion, as we currently do not have a Uri we can pass to the Spotify API to delete local files in playlists - Mark local files in `ListView` fixes #1213
This commit is contained in:
@@ -220,6 +220,7 @@ impl<I: ListItem + Clone> View for ListView<I> {
|
||||
let item = &content[i];
|
||||
let currently_playing =
|
||||
item.is_playing(&self.queue) && self.queue.get_current_index() == Some(i);
|
||||
let is_local = item.track().map(|t| t.is_local).unwrap_or_default();
|
||||
|
||||
let style = if self.selected == i {
|
||||
if currently_playing {
|
||||
@@ -227,6 +228,11 @@ impl<I: ListItem + Clone> View for ListView<I> {
|
||||
*printer.theme.palette.custom("playing_selected").unwrap(),
|
||||
ColorType::Palette(PaletteColor::Highlight),
|
||||
)
|
||||
} else if is_local {
|
||||
ColorStyle::new(
|
||||
ColorType::Palette(PaletteColor::Secondary),
|
||||
ColorType::Palette(PaletteColor::Highlight),
|
||||
)
|
||||
} else {
|
||||
ColorStyle::highlight()
|
||||
}
|
||||
@@ -235,6 +241,8 @@ impl<I: ListItem + Clone> View for ListView<I> {
|
||||
ColorType::Color(*printer.theme.palette.custom("playing").unwrap()),
|
||||
ColorType::Color(*printer.theme.palette.custom("playing_bg").unwrap()),
|
||||
)
|
||||
} else if is_local {
|
||||
ColorStyle::secondary()
|
||||
} else {
|
||||
ColorStyle::primary()
|
||||
};
|
||||
|
||||
@@ -80,13 +80,16 @@ impl ViewExt for PlaylistView {
|
||||
fn on_command(&mut self, s: &mut Cursive, cmd: &Command) -> Result<CommandResult, String> {
|
||||
if let Command::Delete = cmd {
|
||||
let pos = self.list.get_selected_index();
|
||||
if self
|
||||
|
||||
return if self
|
||||
.playlist
|
||||
.delete_track(pos, self.spotify.clone(), &self.library)
|
||||
{
|
||||
self.list.remove(pos);
|
||||
}
|
||||
return Ok(CommandResult::Consumed(None));
|
||||
Ok(CommandResult::Consumed(None))
|
||||
} else {
|
||||
Err("Could not delete track.".to_string())
|
||||
};
|
||||
}
|
||||
|
||||
if let Command::Sort(key, direction) = cmd {
|
||||
|
||||
Reference in New Issue
Block a user