diff options
author | Florrie <towerofnix@gmail.com> | 2019-10-17 12:08:42 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2019-10-17 12:08:42 -0300 |
commit | 1d1483a9dc18d7acf4267727893a281b99645c02 (patch) | |
tree | dce43df88cfaf3d9422429dcf1f242020e2a52b8 /playlist-utils.js | |
parent | dd1d5c0cb646c2bf9dd189b0e81892a676bf25cb (diff) |
Don't include non-tracks in total track count
Diffstat (limited to 'playlist-utils.js')
-rw-r--r-- | playlist-utils.js | 12 |
1 files changed, 7 insertions, 5 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, |