From 6311eb73de02308b156db61f84adc0ff69d5d737 Mon Sep 17 00:00:00 2001 From: Andy Russo <88431411+AndyRusso@users.noreply.github.com> Date: Sat, 16 Mar 2024 21:00:50 +0500 Subject: [PATCH] feat: PlaylistAddModal switches to created playlist --- src/components/CreatePlaylistModal.vue | 2 +- src/components/PlaylistAddModal.vue | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/components/CreatePlaylistModal.vue b/src/components/CreatePlaylistModal.vue index 43f026f1..cadcb541 100644 --- a/src/components/CreatePlaylistModal.vue +++ b/src/components/CreatePlaylistModal.vue @@ -43,7 +43,7 @@ export default { this.createPlaylist(this.playlistName).then(response => { if (response.error) alert(response.error); else { - this.$emit("created"); + this.$emit("created", response.playlistId, this.playlistName); this.$emit("close"); } }); diff --git a/src/components/PlaylistAddModal.vue b/src/components/PlaylistAddModal.vue index 10910b56..09cc3432 100644 --- a/src/components/PlaylistAddModal.vue +++ b/src/components/PlaylistAddModal.vue @@ -22,7 +22,7 @@ @@ -55,7 +55,9 @@ export default { }; }, mounted() { - this.fetchPlaylists(); + this.getPlaylists().then(json => { + this.playlists = json; + }); this.selectedPlaylist = this.getPreferenceString("selectedPlaylist" + this.hashCode(this.authApiUrl())); window.addEventListener("keydown", this.handleKeyDown); window.blur(); @@ -87,10 +89,9 @@ export default { if (json.error) alert(json.error); }); }, - async fetchPlaylists() { - this.getPlaylists().then(json => { - this.playlists = json; - }); + addCreatedPlaylist(playlistId, playlistName) { + this.playlists.push({ id: playlistId, name: playlistName }); + this.selectedPlaylist = playlistId; }, }, };