working on more reliable, app.inLibrary([MediaItems]) function, applied

This commit is contained in:
booploops 2022-01-05 08:38:09 -08:00
parent fbcfb07937
commit 62b41c2848

View file

@ -2394,6 +2394,27 @@ const app = new Vue({
self.search.resultsSocial = results
})
},
async inLibrary(items = []) {
let types = []
for (let item of items) {
let type = item.type
if (type.slice(-1) != "s") {
type += "s"
}
let id = item.playParams.catalogId ? item.playParams.catalogId : item.id
let index = types.findIndex(function (type) {
return type.type == this
}, type)
if (index == -1) {
types.push({type: type, id: [id]})
} else {
types[index].id.push(id)
}
}
return await this.mk.api.catalogResources(types, {"omit[resource]": "autos", relate: "library", fields: "inLibrary"})
},
isInLibrary(playParams) {
let self = this
let id = ""
@ -2759,7 +2780,9 @@ const app = new Vue({
}
},
{
"id": "addToLibrary",
"name": "Add to Library...",
"disabled": false,
"action": function () {
app.addToLibrary(item_id);
// if (!isLibrary) {app.addToLibrary(item_id); this.mk.nowPlayingItem.attributes.playParams["isLibrary"] = true} else { app.removeFromLibrary(data_type,item_id); this.mk.nowPlayingItem.attributes.playParams["isLibrary"] = false};
@ -2815,6 +2838,16 @@ const app = new Vue({
menus.normal.items = menus.normal.items.concat(this.contextExt.normal)
}
}
// isLibrary = await app.inLibrary([this.mk.nowPlayingItem])
// console.warn(isLibrary)
// if(isLibrary.length != 0) {
// if (isLibrary[0].attributes.inLibrary) {
// menus.normal.items.find(x => x.id == "addToLibrary").disabled = true
// }
// }else{
// menus.normal.items.find(x => x.id == "addToLibrary").disabled = true
// }
let rating = await app.getRating(app.mk.nowPlayingItem)
if(rating == 0) {
menus.normal.items.find(x => x.id == 'love').disabled = false