Fix removing listview item even if not succesfully deleted (#404)
* Fix deleting listview item if not deleted * Refactor
This commit is contained in:
@@ -75,13 +75,18 @@ impl Playlist {
|
||||
track_pos_pairs: &[(Track, usize)],
|
||||
spotify: Arc<Spotify>,
|
||||
library: Arc<Library>,
|
||||
) {
|
||||
if spotify.delete_tracks(&self.id, track_pos_pairs) {
|
||||
if let Some(tracks) = &mut self.tracks {
|
||||
for (_track, pos) in track_pos_pairs {
|
||||
tracks.remove(*pos);
|
||||
) -> bool {
|
||||
match spotify.delete_tracks(&self.id, track_pos_pairs) {
|
||||
false => false,
|
||||
true => {
|
||||
if let Some(tracks) = &mut self.tracks {
|
||||
for (_track, pos) in track_pos_pairs {
|
||||
tracks.remove(*pos);
|
||||
}
|
||||
library.playlist_update(&self);
|
||||
}
|
||||
library.playlist_update(&self);
|
||||
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,12 +62,13 @@ impl ViewExt for PlaylistView {
|
||||
};
|
||||
let track = tracks.get(pos);
|
||||
if let Some(t) = track {
|
||||
self.playlist.delete_tracks(
|
||||
if self.playlist.delete_tracks(
|
||||
&[(t.clone(), pos)],
|
||||
self.spotify.clone(),
|
||||
self.library.clone(),
|
||||
);
|
||||
self.list.remove(pos);
|
||||
) {
|
||||
self.list.remove(pos);
|
||||
}
|
||||
}
|
||||
return Ok(CommandResult::Consumed(None));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user