implement deletion of playlists

closes #11
This commit is contained in:
Henrik Friedrichsen
2019-03-26 22:24:20 +01:00
parent 0e3c9fc504
commit 83a394790f
6 changed files with 57 additions and 3 deletions

View File

@@ -150,6 +150,16 @@ impl Playlists {
store.len() - 1
}
pub fn delete_playlist(&self, id: &str) {
let mut store = self.store.write().expect("can't writelock playlists");
if let Some(position) = store.iter().position(|ref i| i.meta.id == id) {
if self.spotify.delete_playlist(id) {
store.remove(position);
self.save_cache();
}
}
}
pub fn overwrite_playlist(&self, id: &str, tracks: &[Track]) {
debug!("saving {} tracks to {}", tracks.len(), id);
self.spotify.overwrite_playlist(id, &tracks);