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 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'playlist-utils.js') 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, -- cgit 1.3.0-6-gf8a5