fix for collection list on v3

This commit is contained in:
booploops 2022-01-18 02:43:15 -08:00
parent cd48e25acc
commit ea9a11ce25
2 changed files with 54 additions and 64 deletions

View file

@ -249,6 +249,11 @@ const app = new Vue({
start: 0,
end: 0
},
v3: {
requestBody: {
platform: "web"
}
},
tmpVar: [],
notification: false,
chrome: {
@ -881,15 +886,18 @@ const app = new Vue({
})
}
},
async showCollection(response, title, type) {
async showCollection(response, title, type, requestBody = {}) {
let self = this
console.log(response)
this.collectionList.requestBody = {}
this.collectionList.response = response
this.collectionList.title = title
this.collectionList.type = type
this.collectionList.requestBody = requestBody
app.appRoute("collection-list")
},
async showArtistView(artist, title, view) {
let response = (await app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/artists/${artist}/view/${view}`)).data
let response = (await app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/artists/${artist}/view/${view}`,{}, {includeResponseMeta: !0})).data
console.log(response)
await this.showCollection(response, title, "artists")
},
@ -898,7 +906,8 @@ const app = new Vue({
await this.showCollection(response, title, "record-labels")
},
async showSearchView(term, group, title) {
let response = await app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/search?term=${term}`, {
let requestBody = {
platform: "web",
groups: group,
types: "activities,albums,apple-curators,artists,curators,editorial-items,music-movies,music-videos,playlists,songs,stations,tv-episodes,uploaded-videos,record-labels",
@ -924,14 +933,18 @@ const app = new Vue({
resource: ["autos"]
},
groups: group
}
let response = await app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/search?term=${term}`, requestBody , {
includeResponseMeta: !0
})
console.log('searchres', response)
let responseFormat = {
data: response.data.results[group].data,
next: response.data.results[group].data,
next: response.data.results[group].next,
groups: group
}
await this.showCollection(responseFormat, title, "search")
await this.showCollection(responseFormat, title, "search", requestBody)
},
async getPlaylistContinuous(response, transient = false) {
response = response.data.data[0]

View file

@ -14,13 +14,16 @@
<mediaitem-square v-else :item="item" :type="getKind(item)"></mediaitem-square>
</template>
</template>
<button v-if="triggerEnabled" style="opacity:0;height: 32px;" v-observe-visibility="{callback: visibilityChanged}">Show More</button>
<button v-if="triggerEnabled" style="opacity:0;height: 32px;"
v-observe-visibility="{callback: visibilityChanged}">Show More
</button>
</div>
<transition name="fabfade">
<button class="top-fab" v-show="showFab" @click="scrollToTop()">
<%- include("../svg/arrow-up.svg") %>
</button>
</transition>
<div class="well" v-show="loading"><div class="spinner"></div></div>
</div>
</script>
<script>
@ -47,7 +50,8 @@
canSeeTrigger: false,
showFab: false,
commonKind: "song",
api: this.$root.mk.api
api: this.$root.mk.api,
loading: false
}
},
methods: {
@ -71,60 +75,33 @@
})
},
getNext() {
// if this.data.next is not null, then we can run this.data.next() and concat to this.data.data to get the next page
switch(this.type) {
default:
case "artists":
if (this.data.next && this.triggerEnabled) {
let self = this
this.triggerEnabled = false;
this.loading = true
let nextFn = (data => {
console.log(data);
this.data.next = data.next;
this.data.data = this.data.data.concat(data.data);
this.triggerEnabled = true;
});
if(typeof this.data.next == "function") {
this.data.next().then(data => nextFn(data));
}else{
this.api.v3.music(this.data.next).then(data => nextFn(data));
}
}else{
console.log("No next page");
this.triggerEnabled = false;
}
break;
case "search":
if (this.data.next && this.triggerEnabled) {
this.triggerEnabled = false;
this.data.next().then(data => {
console.log(data);
this.data.next = data[this.data.groups].next;
this.data.data = this.data.data.concat(data[this.data.groups].data.data);
this.triggerEnabled = true;
});
}else{
console.log("No next page");
this.triggerEnabled = false;
}
break;
case "listen_now":
case "curator":
if (this.data.next && this.triggerEnabled) {
this.triggerEnabled = false;
app.mk.api.v3.music(this.data.next).then(data => {
console.log(data);
this.data.next = data.data.next;
this.data.data = this.data.data.concat(data.data.data);
this.triggerEnabled = true;
});
}else{
console.log("No next page");
this.triggerEnabled = false;
}
break;
if (this.data.next == "undefined") {
return
}
this.api.v3.music(this.data.next, app.collectionList.requestBody).then((response) => {
if (!app.collectionList.response.groups) {
if (response.data.next) {
this.data.data = this.data.data.concat(response.data.data);
this.data.next = response.data.next;
this.triggerEnabled = true;
this.loading = false
}
}else{
if (response.data.results[app.collectionList.response.groups].next) {
this.data.data = this.data.data.concat(response.data.results[app.collectionList.response.groups].data);
this.data.next = response.data.results[app.collectionList.response.groups].next;
this.triggerEnabled = true;
this.loading = false
}
}
})
},
headerVisibility: function (isVisible, entry) {
if (isVisible) {