diff options
author | Florrie <towerofnix@gmail.com> | 2018-10-11 13:22:25 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2018-10-11 13:22:25 -0300 |
commit | 5266a643e9e8dc33dd8ad74e8a0359e2888209a4 (patch) | |
tree | c76a5c95ca2edfb3287b827028b05a9d6ec62bb9 | |
parent | 68ca78ee4b6e0a84d1b39257a395365a636d6a0f (diff) |
Don't queue groups in the wrong order!
-rw-r--r-- | ui.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/ui.js b/ui.js index 15c0d34..cf45a4b 100644 --- a/ui.js +++ b/ui.js @@ -441,6 +441,14 @@ class AppElement extends FocusElement { async queueGrouplikeItem(topItem, afterItem = null, {movePlayingTrack = true} = {}) { const newTrackIndex = this.queueGrouplike.items.length + // The position which new tracks should be added at, if afterItem is + // passed. + const afterIndex = afterItem && this.queueGrouplike.items.indexOf(afterItem) + + // Keeps track of how many tracks have been added; this is used so that + // a whole group can be queued in order after a given item. + let grouplikeOffset = 0 + const recursivelyAddTracks = item => { // For groups, just queue all children. if (isGroup(item)) { @@ -471,11 +479,13 @@ class AppElement extends FocusElement { if (afterItem === 'FRONT') { items.unshift(item) - } else if (afterItem && items.includes(afterItem)) { - items.splice(items.indexOf(afterItem) + 1, 0, item) + } else if (afterItem) { + items.splice(afterIndex + 1 + grouplikeOffset, 0, item) } else { items.push(item) } + + grouplikeOffset++ } recursivelyAddTracks(topItem) |