From d7be56f65ba242271de91087b09690f581b9cfde Mon Sep 17 00:00:00 2001 From: Core Date: Sat, 17 Sep 2022 01:06:19 +0100 Subject: [PATCH] moved function outside to stop redefine [ci skip] --- src/renderer/main/vueapp.js | 45 ++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/renderer/main/vueapp.js b/src/renderer/main/vueapp.js index 0ca0f6f3..1bf457d5 100644 --- a/src/renderer/main/vueapp.js +++ b/src/renderer/main/vueapp.js @@ -679,6 +679,26 @@ const app = new Vue({ }); return isInPlaylist; }, + addToPlaylist(pid, pitems) { + app.mk.api.v3 + .music( + `/v1/me/library/playlists/${pid}/tracks`, + {}, + { + fetchOptions: { + method: "POST", + body: JSON.stringify({ + data: pitems, + }), + }, + } + ) + .then(() => { + if (app.page === "playlist_" + pid) { + app.getPlaylistFromID(app.showingPlaylist.id, true); + } + }); + }, async addSelectedToPlaylist(playlist_id) { let self = this; let pl_items = []; @@ -724,35 +744,14 @@ const app = new Vue({ } this.modals.addToPlaylist = false; - function addToPlaylist(pid, pitems) { - app.mk.api.v3 - .music( - `/v1/me/library/playlists/${pid}/tracks`, - {}, - { - fetchOptions: { - method: "POST", - body: JSON.stringify({ - data: pitems, - }), - }, - } - ) - .then(() => { - if (app.page === "playlist_" + pid) { - app.getPlaylistFromID(app.showingPlaylist.id, true); - } - }); - } - if (await this.isSongInPlaylist(song_ids, playlist_id)) { app.confirm(app.getLz("action.addToPlaylist.duplicate"), (result) => { if (result === true) { - addToPlaylist(playlist_id, pl_items); + app.addToPlaylist(playlist_id, pl_items); } }); } else { - addToPlaylist(playlist_id, pl_items); + app.addToPlaylist(playlist_id, pl_items); } }, async init() {