From aaf7df8ab303b4ee3a2efc38cb51ec7671930ec8 Mon Sep 17 00:00:00 2001 From: booploops <49113086+booploops@users.noreply.github.com> Date: Wed, 22 Dec 2021 16:54:22 -0800 Subject: [PATCH] improvements to playlist creation and deletion --- src/renderer/index.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/renderer/index.js b/src/renderer/index.js index 1179b4e7..74a571e3 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -485,7 +485,7 @@ const app = new Vue({ self.refreshPlaylists() }) }, - async newPlaylist(name = "New Playlist", tracks = []) { + newPlaylist(name = "New Playlist", tracks = []) { let self = this let request = { name: name @@ -493,17 +493,25 @@ const app = new Vue({ if(tracks.length > 0) { request.tracks = tracks } - await app.mk.api.library.createPlaylist(request).then(res => { + app.mk.api.library.createPlaylist(request).then(res => { console.log(res) - self.refreshPlaylists() self.appRoute(`playlist_` + res.id); + self.showingPlaylist = []; + self.getPlaylistFromID(app.page.substring(9)) + setTimeout(() => { + app.refreshPlaylists() + }, 3000) }) }, - async deletePlaylist(id) { + deletePlaylist(id) { let self = this if(confirm(`Are you sure you want to delete this playlist?`)) { - await app.mk.api.library.deletePlaylist(id).then(res=>{ - self.refreshPlaylists() + app.mk.api.library.deletePlaylist(id).then(res=>{ + // remove this playlist from playlists.listing if it exists + let found = self.playlists.listing.find(item => item.id == id) + if(found) { + self.playlists.listing.splice(self.playlists.listing.indexOf(found), 1) + } }) } },