diff --git a/src/renderer/index.js b/src/renderer/index.js index 0f8915aa..2fd46725 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -658,17 +658,51 @@ const app = new Vue({ action: () => { this.newPlaylist() } + }, + { + name: "New Playlist Folder", + action: () => { + this.newPlaylistFolder() + } } ] } CiderContextMenu.Create(event, menu) }, - async editPlaylist(id, name = "New Playlist") { + async editPlaylistFolder(id, name = "New Playlist") { let self = this - await app.mk.api.library.editPlaylist(id, {name: name}).then(res => { + this.mk.api.v3.music( + `/v1/me/library/playlist-folders/${id}`, + {}, + { + fetchOptions: { + method: "PATCH", + body: JSON.stringify({ + attributes: {name: name} + }) + } + } + ).then(res => { self.refreshPlaylists() }) }, + async editPlaylist(id, name = "New Playlist") { + let self = this + this.mk.api.v3.music( + `/v1/me/library/playlists/${id}`, + {}, + { + fetchOptions: { + method: "PATCH", + body: JSON.stringify({ + attributes: {name: name} + }) + } + } + ).then(res => { + self.refreshPlaylists() + }) + }, copyToClipboard(str) { navigator.clipboard.writeText(str) }, @@ -1718,7 +1752,8 @@ const app = new Vue({ this.getMadeForYou(attempt + 1) } }, - createPlaylistFolder(name = "New Folder") { + newPlaylistFolder(name = "New Folder") { + let self = this this.mk.api.v3.music( "/v1/me/library/playlist-folders/", {}, @@ -1730,10 +1765,20 @@ const app = new Vue({ }) } } - ).then(() => { + ).then((res) => { + let playlist = (res.data.data[0]) + self.playlists.listing.push({ + id: playlist.id, + attributes: { + name: playlist.attributes.name + }, + type: "library-playlist-folders", + parent: "p.playlistsroot" + }) + self.sortPlaylists() setTimeout(() => { app.refreshPlaylists() - }, 3000) + }, 13000) }) }, unauthorize() { diff --git a/src/renderer/views/components/sidebar-playlist.ejs b/src/renderer/views/components/sidebar-playlist.ejs index 5fe152f5..9a85e59f 100644 --- a/src/renderer/views/components/sidebar-playlist.ejs +++ b/src/renderer/views/components/sidebar-playlist.ejs @@ -8,7 +8,10 @@ @drop="onDrop" :href="item.href" @click='$root.appRoute(`playlist_` + item.id); $root.showingPlaylist = [];$root.getPlaylistFromID($root.page.substring(9))'> - {{ item.attributes.name }} + +