fix add to lib for suggestion contextmenu
This commit is contained in:
parent
9bbbb6d276
commit
74e1e3d38a
1 changed files with 23 additions and 1 deletions
|
@ -50,6 +50,28 @@
|
||||||
async mounted() {
|
async mounted() {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
async isInLibrary() {
|
||||||
|
if (this.item.type && !this.item.type.includes("library")) {
|
||||||
|
let params = {
|
||||||
|
relate: "library",
|
||||||
|
"fields": "inLibrary",
|
||||||
|
"extend": this.revisedRandId()
|
||||||
|
}
|
||||||
|
let kind = this.item.type ?? this.item.attributes.playParams.kind
|
||||||
|
let truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
|
||||||
|
if (truekind === "musicVideos") {
|
||||||
|
truekind = "music-videos"
|
||||||
|
}
|
||||||
|
let res = await app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/?ids[${truekind}]=${this.item.attributes.playParams.id ?? this.item.id}`, params);
|
||||||
|
res = res.data.data[0]
|
||||||
|
this.addedToLibrary = (res && res.attributes && res.attributes.inLibrary) ? res.attributes.inLibrary : false
|
||||||
|
} else {
|
||||||
|
this.addedToLibrary = true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
revisedRandId() {
|
||||||
|
return Math.random().toString(36).replace(/[^a-z]+/g, '').slice(2, 10);
|
||||||
|
},
|
||||||
uuidv4() {
|
uuidv4() {
|
||||||
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
|
||||||
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
|
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
|
||||||
|
@ -276,7 +298,7 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
let rating = await app.getRating(self.item)
|
let rating = await app.getRating(self.item)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue