From 7ad11a436b04c18a8c45076cc52f783b9d07c44b Mon Sep 17 00:00:00 2001 From: booploops <49113086+booploops@users.noreply.github.com> Date: Wed, 23 Feb 2022 18:35:28 -0800 Subject: [PATCH] fix for add to library on nowplaying --- src/renderer/index.js | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/renderer/index.js b/src/renderer/index.js index b42987a4..48ce8d7a 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -3568,22 +3568,32 @@ const app = new Vue({ } }, ], - items: [{ - "icon": "./assets/feather/list.svg", - "name": app.getLz('action.addToPlaylist') + " ...", - "action": function () { - app.promptAddToPlaylist() - } - }, + items: [ { "icon": "./assets/feather/plus.svg", "id": "addToLibrary", "name": app.getLz('action.addToLibrary') + " ...", - "disabled": false, + "disabled": true, "action": function () { app.addToLibrary(app.mk.nowPlayingItem.id); } }, + { + "id": "removeFromLibrary", + "icon": "./assets/feather/x-circle.svg", + "name": app.getLz('action.removeFromLibrary'), + "hidden": true, + "action": function () { + self.removeFromLibrary() + } + }, + { + "icon": "./assets/feather/list.svg", + "name": app.getLz('action.addToPlaylist') + " ...", + "action": function () { + app.promptAddToPlaylist() + } + }, { "icon": "./assets/feather/radio.svg", "name": app.getLz('action.startRadio'), @@ -3636,6 +3646,18 @@ const app = new Vue({ } this.showMenuPanel(menus[useMenu], event) + try { + let result = await this.inLibrary([this.mk.nowPlayingItem]) + if (result[0].attributes.inLibrary) { + 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) { + e = null + } + try { let rating = await app.getRating(app.mk.nowPlayingItem) if (rating == 0) {