From 5266a643e9e8dc33dd8ad74e8a0359e2888209a4 Mon Sep 17 00:00:00 2001 From: Florrie Date: Thu, 11 Oct 2018 13:22:25 -0300 Subject: Don't queue groups in the wrong order! --- ui.js | 14 ++++++++++++-- 1 file 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) -- cgit 1.3.0-6-gf8a5