use async on isinLibrary on square
This commit is contained in:
parent
8c69168a69
commit
917298b6a5
1 changed files with 37 additions and 19 deletions
|
@ -245,7 +245,6 @@
|
||||||
} else {
|
} else {
|
||||||
console.log(event)
|
console.log(event)
|
||||||
}
|
}
|
||||||
await this.isInLibrary();
|
|
||||||
let self = this
|
let self = this
|
||||||
let useMenu = "normal"
|
let useMenu = "normal"
|
||||||
if (app.selectedMediaItems.length <= 1) {
|
if (app.selectedMediaItems.length <= 1) {
|
||||||
|
@ -352,6 +351,30 @@
|
||||||
app.promptAddToPlaylist()
|
app.promptAddToPlaylist()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "addToLibrary",
|
||||||
|
"icon": "./assets/feather/plus.svg",
|
||||||
|
"name": "Add to library",
|
||||||
|
"hidden": false,
|
||||||
|
"disabled": true,
|
||||||
|
"action": function () {
|
||||||
|
let item_id = self.item.attributes.playParams.id ?? self.item.id;
|
||||||
|
let data_type = self.item.attributes.playParams.kind ?? self.item.type;
|
||||||
|
app.addToLibrary(item_id);
|
||||||
|
self.addedToLibrary = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "removeFromLibrary",
|
||||||
|
"icon": "./assets/feather/x-circle.svg",
|
||||||
|
"name": "Remove from library",
|
||||||
|
"hidden": true,
|
||||||
|
"action": async function () {
|
||||||
|
console.log("remove");
|
||||||
|
await self.removeFromLibrary(item_id);
|
||||||
|
self.addedToLibrary = false
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Play Next",
|
"name": "Play Next",
|
||||||
"action": function () {
|
"action": function () {
|
||||||
|
@ -368,24 +391,6 @@
|
||||||
app.selectedMediaItems = []
|
app.selectedMediaItems = []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"icon": "./assets/feather/plus.svg",
|
|
||||||
"name": (this.addedToLibrary) ? "Remove from Library..." : "Add to Library...",
|
|
||||||
"action": async function () {
|
|
||||||
let item_id = self.item.attributes.playParams.id ?? self.item.id;
|
|
||||||
let data_type = self.item.attributes.playParams.kind ?? self.item.type;
|
|
||||||
if (self.addedToLibrary != true) {
|
|
||||||
console.log("add");
|
|
||||||
app.addToLibrary(item_id);
|
|
||||||
self.addedToLibrary = true
|
|
||||||
} else {
|
|
||||||
console.log("remove");
|
|
||||||
await self.removeFromLibrary(item_id);
|
|
||||||
self.addedToLibrary = false
|
|
||||||
}
|
|
||||||
;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"icon": "./assets/feather/share.svg",
|
"icon": "./assets/feather/share.svg",
|
||||||
"name": "Share",
|
"name": "Share",
|
||||||
|
@ -404,6 +409,19 @@
|
||||||
}
|
}
|
||||||
app.showMenuPanel(menus[useMenu], event)
|
app.showMenuPanel(menus[useMenu], event)
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.isInLibrary().then((_) => {
|
||||||
|
if(self.addedToLibrary) {
|
||||||
|
menus.normal.items.find(x => x.id == 'addToLibrary').hidden = true
|
||||||
|
menus.normal.items.find(x => x.id == 'removeFromLibrary').hidden = false
|
||||||
|
}else{
|
||||||
|
menus.normal.items.find(x => x.id == 'addToLibrary').disabled = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}catch(e) {
|
||||||
|
|
||||||
|
}
|
||||||
try{
|
try{
|
||||||
let rating = await app.getRating(self.item)
|
let rating = await app.getRating(self.item)
|
||||||
if (rating == 0) {
|
if (rating == 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue