From e8a55f10dd9749ad240b165e318db0a1d2f00a9a Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 1 Jun 2022 23:35:03 -0300 Subject: miscellaneous improvements to queue looping --- backend.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'backend.js') diff --git a/backend.js b/backend.js index 36344be..59c4a48 100644 --- a/backend.js +++ b/backend.js @@ -338,9 +338,11 @@ class QueuePlayer extends EventEmitter { } } - shuffleQueue() { + shuffleQueue(pastPlayingTrackOnly = true) { const queue = this.queueGrouplike - const index = queue.items.indexOf(this.playingTrack) + 1 // This is 0 if no track is playing + const index = (pastPlayingTrackOnly + ? queue.items.indexOf(this.playingTrack) + 1 // This is 0 if no track is playing + : 0) const initialItems = queue.items.slice(0, index) const remainingItems = queue.items.slice(index) const newItems = initialItems.concat(shuffleArray(remainingItems)) @@ -517,8 +519,7 @@ class QueuePlayer extends EventEmitter { this.playFirst() return true case 'shuffle': - this.clearPlayingTrack() - this.shuffleQueue() + this.shuffleQueue(false) this.playFirst() return true case 'end': -- cgit 1.3.0-6-gf8a5