Shows 10 Recently Played Songs & Albums in Search Page inside individual Media-Square Item.

This commit is contained in:
Monochromish 2022-04-12 21:27:20 +10:00
parent a5f73117fb
commit 676655b3b4

View file

@ -83,6 +83,8 @@
<div v-if="categoriesReady || getCategories()"> <div v-if="categoriesReady || getCategories()">
<div> <div>
<div class="col" v-if="categoriesView != null && categoriesView != [] && categoriesView[0].attributes != null && categoriesView[0].attributes.title != null"> <div class="col" v-if="categoriesView != null && categoriesView != [] && categoriesView[0].attributes != null && categoriesView[0].attributes.title != null">
<h3>{{$root.getLz('home.recentlyPlayed')}}</h3>
<mediaitem-square :kind="'385'" size="600" v-for="item in recentlyPlayed.limit(10)" :item="item" :imagesize="800"></mediaitem-square>
<h3>{{categoriesView[0].attributes.title.stringForDisplay ?? ""}}</h3> <h3>{{categoriesView[0].attributes.title.stringForDisplay ?? ""}}</h3>
</div> </div>
<mediaitem-square :kind="'385'" size="600" <mediaitem-square :kind="'385'" size="600"
@ -102,6 +104,7 @@
data: function () { data: function () {
return { return {
app: this.$root, app: this.$root,
recentlyPlayed: [],
categoriesView: [], categoriesView: [],
categoriesReady: false, categoriesReady: false,
} }
@ -114,8 +117,15 @@
return false return false
} }
}, },
async seeAllHistory() {
let hist = await app.mk.api.v3.music(`/v1/me/recent/played/tracks`, {
l: this.$root.mklang
})
this.recentlyPlayed = hist.data.data
},
async getCategories() { async getCategories() {
if (this.categoriesView != [] && this.categoriesView.length > 0) { this.categoriesReady = true; return await true; } else { if (this.categoriesView != [] && this.categoriesView.length > 0) { this.categoriesReady = true; return await true; } else {
await this.seeAllHistory()
let response = await this.app.mk.api.v3.music(`/v1/recommendations/${this.app.mk.storefrontId}?timezone=${encodeURIComponent(this.app.formatTimezoneOffset())}&name=search-landing&platform=web&extend=editorialArtwork&art%5Burl%5D=f%2Cc&types=editorial-items%2Capple-curators%2Cactivities&l=${this.$root.mklang}`); let response = await this.app.mk.api.v3.music(`/v1/recommendations/${this.app.mk.storefrontId}?timezone=${encodeURIComponent(this.app.formatTimezoneOffset())}&name=search-landing&platform=web&extend=editorialArtwork&art%5Burl%5D=f%2Cc&types=editorial-items%2Capple-curators%2Cactivities&l=${this.$root.mklang}`);
this.categoriesView = response.data.data; this.categoriesView = response.data.data;
console.log(this.categoriesView) console.log(this.categoriesView)