downloads entire library in songs view
This commit is contained in:
parent
10dba24da2
commit
4e051eb97c
2 changed files with 55 additions and 12 deletions
|
@ -252,20 +252,27 @@
|
||||||
</template>
|
</template>
|
||||||
</transition>
|
</transition>
|
||||||
<!-- Library - Songs -->
|
<!-- Library - Songs -->
|
||||||
<transition name="wpfade" v-on:enter="getLibrarySongs()">
|
<transition name="wpfade" v-on:enter="getLibrarySongsFull()">
|
||||||
<template v-if="page == 'library-songs'">
|
<template v-if="page == 'library-songs'">
|
||||||
<div class="content-inner">
|
<div class="content-inner">
|
||||||
<h1 class="header-text">Songs</h1>
|
<h1 class="header-text">Songs</h1>
|
||||||
<div class="search-input-container" style="width:100%;margin: 16px 0px;">
|
<template v-if="library.songs.downloadState == 1">
|
||||||
<div class="search-input--icon"></div>
|
<h1 style="text-align: center">Downloading...</h1>
|
||||||
<input type="search"
|
<h3 style="text-align: center">{{ library.songs.meta.progress }} / {{ library.songs.meta.total }}</h3>
|
||||||
style="width:100%;"
|
|
||||||
spellcheck="false"
|
</template>
|
||||||
placeholder="Search..."
|
<template v-if="library.songs.downloadState == 2">
|
||||||
class="search-input">
|
<div class="search-input-container" style="width:100%;margin: 16px 0px;">
|
||||||
</div>
|
<div class="search-input--icon"></div>
|
||||||
<mediaitem-list-item :item="item"
|
<input type="search"
|
||||||
v-for="item in library.songs.listing"></mediaitem-list-item>
|
style="width:100%;"
|
||||||
|
spellcheck="false"
|
||||||
|
placeholder="Search..."
|
||||||
|
class="search-input">
|
||||||
|
</div>
|
||||||
|
<mediaitem-list-item :item="item"
|
||||||
|
v-for="item in library.songs.listing"></mediaitem-list-item>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</transition>
|
</transition>
|
||||||
|
|
|
@ -107,7 +107,8 @@ const app = new Vue({
|
||||||
library: {
|
library: {
|
||||||
songs: {
|
songs: {
|
||||||
listing: [],
|
listing: [],
|
||||||
meta: {total: 0}
|
meta: {total: 0, progress: 0},
|
||||||
|
downloadState: 0 // 0 = not started, 1 = in progress, 2 = complete
|
||||||
},
|
},
|
||||||
albums: {
|
albums: {
|
||||||
listing: [],
|
listing: [],
|
||||||
|
@ -174,6 +175,41 @@ const app = new Vue({
|
||||||
return await this.mkapi(method, library, term, params, params2, attempts + 1)
|
return await this.mkapi(method, library, term, params, params2, attempts + 1)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async getLibrarySongsFull () {
|
||||||
|
let self = this
|
||||||
|
let library = []
|
||||||
|
let downloaded = null;
|
||||||
|
if(this.library.songs.downloadState == 2 || this.library.songs.downloadState == 1) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.library.songs.downloadState = 1
|
||||||
|
function downloadChunk () {
|
||||||
|
if(downloaded == null) {
|
||||||
|
app.mk.api.library.songs("", {limit: 100}, {includeResponseMeta: !0}).then((response)=>{
|
||||||
|
processChunk(response)
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
downloaded.next("", {limit: 100}, {includeResponseMeta: !0}).then((response)=>{
|
||||||
|
processChunk(response)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function processChunk (response) {
|
||||||
|
downloaded = response
|
||||||
|
library = library.concat(downloaded.data)
|
||||||
|
self.library.songs.meta.total = downloaded.meta.total
|
||||||
|
self.library.songs.meta.progress = library.length
|
||||||
|
if (downloaded.meta.total > library.length) {
|
||||||
|
console.log(`downloading next chunk - ${library.length} songs so far`)
|
||||||
|
downloadChunk()
|
||||||
|
} else {
|
||||||
|
self.library.songs.listing = library
|
||||||
|
self.library.songs.downloadState = 2
|
||||||
|
console.log(library)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
downloadChunk()
|
||||||
|
},
|
||||||
async getLibrarySongs() {
|
async getLibrarySongs() {
|
||||||
var response = await this.mkapi("songs", true, "", {limit: 100}, {includeResponseMeta: !0})
|
var response = await this.mkapi("songs", true, "", {limit: 100}, {includeResponseMeta: !0})
|
||||||
this.library.songs.listing = response.data
|
this.library.songs.listing = response.data
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue