playlist folders will now load recursively
This commit is contained in:
parent
1b5474a81e
commit
bda22b2321
3 changed files with 40 additions and 18 deletions
|
@ -619,15 +619,7 @@ const app = new Vue({
|
||||||
async refreshPlaylists() {
|
async refreshPlaylists() {
|
||||||
let self = this
|
let self = this
|
||||||
this.apiCall('https://api.music.apple.com/v1/me/library/playlist-folders/p.playlistsroot/children/', res => {
|
this.apiCall('https://api.music.apple.com/v1/me/library/playlist-folders/p.playlistsroot/children/', res => {
|
||||||
console.log(res)
|
|
||||||
self.playlists.listing = res.data
|
self.playlists.listing = res.data
|
||||||
self.playlists.listing.forEach(playlist => {
|
|
||||||
if(playlist.type === "library-playlist-folders") {
|
|
||||||
self.mk.api.library.playlistFolderChildren(playlist.id).then(children => {
|
|
||||||
playlist.children = children
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
self.playlists.listing.sort((a, b) => {
|
self.playlists.listing.sort((a, b) => {
|
||||||
if (a.type === "library-playlist-folders" && b.type !== "library-playlist-folders") {
|
if (a.type === "library-playlist-folders" && b.type !== "library-playlist-folders") {
|
||||||
return -1
|
return -1
|
||||||
|
|
|
@ -1654,6 +1654,13 @@ input[type="range"].web-slider.display--small::-webkit-slider-thumb {
|
||||||
background: #ffffff0a;
|
background: #ffffff0a;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
padding: 1px 6px;
|
padding: 1px 6px;
|
||||||
|
|
||||||
|
.spinner {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
height: 32px;
|
||||||
|
background-size: 16px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,23 +8,22 @@
|
||||||
{{ item.attributes.name }}
|
{{ item.attributes.name }}
|
||||||
</button>
|
</button>
|
||||||
<button class="app-sidebar-item" :key="item.id" v-else
|
<button class="app-sidebar-item" :key="item.id" v-else
|
||||||
:class="{'folder-button-active': folderOpened}"
|
:class="[{'folder-button-active': folderOpened}, isPlaylistSelected]"
|
||||||
@contextmenu="$root.playlistContextMenu($event, item.id)"
|
@contextmenu="$root.playlistContextMenu($event, item.id)"
|
||||||
@dragover="()=>{}"
|
@dragover="()=>{}"
|
||||||
:href="item.href"
|
:href="item.href"
|
||||||
@click='toggleFolder'>
|
@click='getPlaylistChildren(item)'>
|
||||||
<span v-if="!folderOpened">📁</span>
|
<span v-if="!folderOpened">📁</span>
|
||||||
<span v-else>📂</span>
|
<span v-else>📂</span>
|
||||||
{{ item.attributes.name }}
|
{{ item.attributes.name }}
|
||||||
</button>
|
</button>
|
||||||
<div class="folder-body" v-if="item.type === 'library-playlist-folders' && folderOpened">
|
<div class="folder-body" v-if="item.type === 'library-playlist-folders' && folderOpened">
|
||||||
<button class="app-sidebar-item" v-for="child in item.children" :key="child.id" v-if="child.type != 'library-playlist-folders'"
|
<template v-if="children.length != 0">
|
||||||
@contextmenu="$root.playlistContextMenu($event, child.id)"
|
<sidebar-playlist v-for="item in children" :item="item" :key="item.id"></sidebar-playlist>
|
||||||
@dragover="()=>{}"
|
</template>
|
||||||
:href="child.href"
|
<template v-else>
|
||||||
@click='$root.appRoute(`playlist_` + child.id); $root.showingPlaylist = [];$root.getPlaylistFromID($root.page.substring(9))'>
|
<div class="spinner"></div>
|
||||||
{{ child.attributes.name }}
|
</template>
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
@ -40,10 +39,34 @@
|
||||||
},
|
},
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
folderOpened: false
|
folderOpened: false,
|
||||||
|
children: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
getPlaylistChildren(item) {
|
||||||
|
let self = this
|
||||||
|
this.toggleFolder()
|
||||||
|
this.$root.mk.api.library.playlistFolderChildren(item.id).then(children => {
|
||||||
|
self.children = children
|
||||||
|
self.children.sort((a, b) => {
|
||||||
|
if (a.type === 'library-playlist-folders' && b.type !== 'library-playlist-folders') {
|
||||||
|
return -1
|
||||||
|
} else if (a.type !== 'library-playlist-folders' && b.type === 'library-playlist-folders') {
|
||||||
|
return 1
|
||||||
|
} else {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
isPlaylistSelected(item) {
|
||||||
|
if(this.$root.showingPlaylist.id == item.id) {
|
||||||
|
return ["active"]
|
||||||
|
} else {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
},
|
||||||
toggleFolder() {
|
toggleFolder() {
|
||||||
this.folderOpened = !this.folderOpened;
|
this.folderOpened = !this.folderOpened;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue