moved function outside to stop redefine
[ci skip]
This commit is contained in:
parent
31e76d540e
commit
d7be56f65b
1 changed files with 22 additions and 23 deletions
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue