From cb1d56defbc72c04e7e28d3c1b2996faa2cf5d1c Mon Sep 17 00:00:00 2001 From: Albin Larsson Date: Thu, 22 Aug 2019 14:08:55 +0200 Subject: [PATCH] if collection has no playable items hide btns --- src/controllers/itemdetailpage.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/controllers/itemdetailpage.js b/src/controllers/itemdetailpage.js index 2afa817cfc..9149d78391 100644 --- a/src/controllers/itemdetailpage.js +++ b/src/controllers/itemdetailpage.js @@ -880,6 +880,16 @@ define(["loading", "appRouter", "layoutManager", "connectionManager", "cardBuild }) } + function canPlaySomeItemInCollection(items) { + var i = 0; + for (length = items.length; i < length; i++) { + if (playbackManager.canPlay(items[i])) { + return true; + } + } + return false; + } + function renderCollectionItems(page, parentItem, types, items) { page.querySelector(".collectionItems").innerHTML = ""; var i, length; @@ -904,6 +914,12 @@ define(["loading", "appRouter", "layoutManager", "connectionManager", "cardBuild renderChildren(page, parentItem) }; for (i = 0, length = containers.length; i < length; i++) containers[i].notifyRefreshNeeded = notifyRefreshNeeded + + // if nothing in the collection can be played hide play and shuffle buttons + if (!canPlaySomeItemInCollection(items)) { + hideAll(page, "btnPlay", false); + hideAll(page, "btnShuffle", false); + } } function renderCollectionItemType(page, parentItem, type, items) {