fix for collection list on v3
This commit is contained in:
parent
cd48e25acc
commit
ea9a11ce25
2 changed files with 54 additions and 64 deletions
|
@ -249,6 +249,11 @@ const app = new Vue({
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 0
|
end: 0
|
||||||
},
|
},
|
||||||
|
v3: {
|
||||||
|
requestBody: {
|
||||||
|
platform: "web"
|
||||||
|
}
|
||||||
|
},
|
||||||
tmpVar: [],
|
tmpVar: [],
|
||||||
notification: false,
|
notification: false,
|
||||||
chrome: {
|
chrome: {
|
||||||
|
@ -881,15 +886,18 @@ const app = new Vue({
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async showCollection(response, title, type) {
|
async showCollection(response, title, type, requestBody = {}) {
|
||||||
let self = this
|
let self = this
|
||||||
|
console.log(response)
|
||||||
|
this.collectionList.requestBody = {}
|
||||||
this.collectionList.response = response
|
this.collectionList.response = response
|
||||||
this.collectionList.title = title
|
this.collectionList.title = title
|
||||||
this.collectionList.type = type
|
this.collectionList.type = type
|
||||||
|
this.collectionList.requestBody = requestBody
|
||||||
app.appRoute("collection-list")
|
app.appRoute("collection-list")
|
||||||
},
|
},
|
||||||
async showArtistView(artist, title, view) {
|
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)
|
console.log(response)
|
||||||
await this.showCollection(response, title, "artists")
|
await this.showCollection(response, title, "artists")
|
||||||
},
|
},
|
||||||
|
@ -898,7 +906,8 @@ const app = new Vue({
|
||||||
await this.showCollection(response, title, "record-labels")
|
await this.showCollection(response, title, "record-labels")
|
||||||
},
|
},
|
||||||
async showSearchView(term, group, title) {
|
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",
|
platform: "web",
|
||||||
groups: group,
|
groups: group,
|
||||||
types: "activities,albums,apple-curators,artists,curators,editorial-items,music-movies,music-videos,playlists,songs,stations,tv-episodes,uploaded-videos,record-labels",
|
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"]
|
resource: ["autos"]
|
||||||
},
|
},
|
||||||
groups: group
|
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)
|
console.log('searchres', response)
|
||||||
let responseFormat = {
|
let responseFormat = {
|
||||||
data: response.data.results[group].data,
|
data: response.data.results[group].data,
|
||||||
next: response.data.results[group].data,
|
next: response.data.results[group].next,
|
||||||
groups: group
|
groups: group
|
||||||
}
|
}
|
||||||
await this.showCollection(responseFormat, title, "search")
|
await this.showCollection(responseFormat, title, "search", requestBody)
|
||||||
},
|
},
|
||||||
async getPlaylistContinuous(response, transient = false) {
|
async getPlaylistContinuous(response, transient = false) {
|
||||||
response = response.data.data[0]
|
response = response.data.data[0]
|
||||||
|
|
|
@ -14,13 +14,16 @@
|
||||||
<mediaitem-square v-else :item="item" :type="getKind(item)"></mediaitem-square>
|
<mediaitem-square v-else :item="item" :type="getKind(item)"></mediaitem-square>
|
||||||
</template>
|
</template>
|
||||||
</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>
|
</div>
|
||||||
<transition name="fabfade">
|
<transition name="fabfade">
|
||||||
<button class="top-fab" v-show="showFab" @click="scrollToTop()">
|
<button class="top-fab" v-show="showFab" @click="scrollToTop()">
|
||||||
<%- include("../svg/arrow-up.svg") %>
|
<%- include("../svg/arrow-up.svg") %>
|
||||||
</button>
|
</button>
|
||||||
</transition>
|
</transition>
|
||||||
|
<div class="well" v-show="loading"><div class="spinner"></div></div>
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
|
@ -47,7 +50,8 @@
|
||||||
canSeeTrigger: false,
|
canSeeTrigger: false,
|
||||||
showFab: false,
|
showFab: false,
|
||||||
commonKind: "song",
|
commonKind: "song",
|
||||||
api: this.$root.mk.api
|
api: this.$root.mk.api,
|
||||||
|
loading: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -71,60 +75,33 @@
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getNext() {
|
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
|
let self = this
|
||||||
switch(this.type) {
|
|
||||||
default:
|
|
||||||
case "artists":
|
|
||||||
if (this.data.next && this.triggerEnabled) {
|
|
||||||
this.triggerEnabled = false;
|
this.triggerEnabled = false;
|
||||||
|
this.loading = true
|
||||||
|
|
||||||
let nextFn = (data => {
|
if (this.data.next == "undefined") {
|
||||||
console.log(data);
|
return
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
headerVisibility: function (isVisible, entry) {
|
||||||
if (isVisible) {
|
if (isVisible) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue