made a better friends listening to. can be accessed on the home page by pressing see all on the section

This commit is contained in:
booploops 2022-01-13 06:07:11 -08:00
parent 9b5cbafdc4
commit cc17c1e666
2 changed files with 40 additions and 2 deletions

View file

@ -290,7 +290,9 @@ const app = new Vue({
},
socialBadges: {
badgeMap: {},
version: ""
version: "",
mediaItems: [],
mediaItemDLState: 0 // 0 = not started, 1 = in progress, 2 = complete
},
menuPanel: {
visible: false,
@ -324,6 +326,29 @@ const app = new Vue({
},
},
methods: {
async showSocialListeningTo() {
let contentIds = Object.keys(app.socialBadges.badgeMap)
app.showCollection({data: this.socialBadges.mediaItems}, "Friends Listening To", "albums")
if(this.socialBadges.mediaItemDLState == 1 || this.socialBadges.mediaItemDLState == 2) {
return
}
this.socialBadges.mediaItemDLState = 2
await asyncForEach(contentIds, async (item)=>{
try {
let type = "albums"
if(item.includes("pl.")) {
type = "playlists"
}
if(item.includes("ra.")) {
type = "stations"
}
let found = await app.mk.api.v3.music(`/v1/catalog/us/${type}/${item}`)
this.socialBadges.mediaItems.push(found.data.data[0])
}catch(e){
}
})
},
async openAppleMusicURL(url) {
let properties = MusicKit.formattedMediaURL(url)
let item = {
@ -3385,6 +3410,12 @@ function xmlToJson(xml) {
return obj;
};
async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array);
}
}
var checkIfScrollIsStatic = setInterval(() => {
try {
if (position === document.getElementsByClassName('lyric-body')[0].scrollTop) {