From 780b44ba6629005d8a9f976bf7117163a65cf717 Mon Sep 17 00:00:00 2001 From: Florrie Date: Mon, 28 Oct 2019 18:56:48 -0300 Subject: Don't show text files adjacent to playables --- playlist-utils.js | 20 ++++++++++++++++++++ ui.js | 5 +++++ 2 files changed, 25 insertions(+) diff --git a/playlist-utils.js b/playlist-utils.js index 082a734..452b705 100644 --- a/playlist-utils.js +++ b/playlist-utils.js @@ -634,6 +634,25 @@ function getCorrespondingFileForItem(item, extension) { return null } +function getCorrespondingPlayableForFile(item) { + if (!(item && item.url)) { + return null + } + + if (isPlayable(item)) { + return item + } + + const parent = item[parentSymbol] + + if (!parent) { + return null + } + + const basename = path.basename(item.url, path.extname(item.url)) + return parent.items.find(item => isPlayable(item) && path.basename(item.url, path.extname(item.url)) === basename) +} + module.exports = { parentSymbol, updatePlaylistFormat, updateGroupFormat, updateTrackFormat, @@ -653,6 +672,7 @@ module.exports = { getNameWithoutTrackNumber, searchForItem, getCorrespondingFileForItem, + getCorrespondingPlayableForFile, isGroup, isTrack, isOpenable, isPlayable } diff --git a/ui.js b/ui.js index 60d9050..70ac1e8 100644 --- a/ui.js +++ b/ui.js @@ -16,6 +16,7 @@ const { countTotalTracks, flattenGrouplike, getCorrespondingFileForItem, + getCorrespondingPlayableForFile, getItemPath, getNameWithoutTrackNumber, isGroup, @@ -1671,6 +1672,10 @@ class GrouplikeListingElement extends Form { // Add the elements for all the actual items within this playlist. for (const item of this.grouplike.items) { + if (!isPlayable(item) && getCorrespondingPlayableForFile(item)) { + continue + } + const itemElement = new InteractiveGrouplikeItemElement(item, this.app) this.addEventListeners(itemElement) form.addInput(itemElement) -- cgit 1.3.0-6-gf8a5