From 1d1483a9dc18d7acf4267727893a281b99645c02 Mon Sep 17 00:00:00 2001 From: Florrie Date: Thu, 17 Oct 2019 12:08:42 -0300 Subject: Don't include non-tracks in total track count --- playlist-utils.js | 12 +++++++----- todo.txt | 3 +++ ui.js | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/playlist-utils.js b/playlist-utils.js index 6119bc3..de2c3f8 100644 --- a/playlist-utils.js +++ b/playlist-utils.js @@ -177,15 +177,17 @@ function flattenGrouplike(grouplike) { } } -function countTotalItems(item) { - // Returns the total number of items in a grouplike, including items in any +function countTotalTracks(item) { + // Returns the total number of tracks in a grouplike, including tracks in any // descendant groups. Basically the same as flattenGrouplike().items.length. if (isGroup(item)) { - return item.items.map(countTotalItems) + return item.items.map(countTotalTracks) .reduce((a, b) => a + b, 0) - } else { + } else if (isTrack(item)) { return 1 + } else { + return 0 } } @@ -603,7 +605,7 @@ module.exports = { updatePlaylistFormat, updateGroupFormat, updateTrackFormat, cloneGrouplike, filterTracks, - flattenGrouplike, countTotalItems, + flattenGrouplike, countTotalTracks, shuffleOrderOfGroups, reverseOrderOfGroups, partiallyFlattenGrouplike, collapseGrouplike, diff --git a/todo.txt b/todo.txt index 0eca376..891479a 100644 --- a/todo.txt +++ b/todo.txt @@ -436,3 +436,6 @@ TODO: A "play (in new player)" option in the play menu. It'd be nice to have TODO: "Shuffle queue", "shuffle these tracks" options in the queue's context menu? + +TODO: It looks like you can't move the currently playing track by re-queuing + it? Investigate this. diff --git a/ui.js b/ui.js index 9a61ec4..03337f5 100644 --- a/ui.js +++ b/ui.js @@ -13,7 +13,7 @@ const { const { cloneGrouplike, - countTotalItems, + countTotalTracks, flattenGrouplike, getItemPath, getNameWithoutTrackNumber, @@ -882,7 +882,7 @@ class AppElement extends FocusElement { canControlQueue && {label: 'Remove from queue', action: () => this.unqueue(item)} ] } else { - const numTracks = countTotalItems(item) + const numTracks = countTotalTracks(item) const { string: durationString } = this.backend.getDuration(item) items = [ // A label that just shows some brief information about the item. -- cgit 1.3.0-6-gf8a5