From 68ca78ee4b6e0a84d1b39257a395365a636d6a0f Mon Sep 17 00:00:00 2001 From: Florrie Date: Thu, 11 Oct 2018 13:14:43 -0300 Subject: Play up next group containing current track nicely --- ui.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ui.js b/ui.js index 6965331..15c0d34 100644 --- a/ui.js +++ b/ui.js @@ -115,7 +115,9 @@ class AppElement extends FocusElement { afterItem = this.playingTrack } - this.queueGrouplikeItem(item, afterItem) + this.queueGrouplikeItem(item, afterItem, { + movePlayingTrack: !shuffle + }) if (play) { this.playGrouplikeItem(item) @@ -436,7 +438,7 @@ class AppElement extends FocusElement { this.player.kill() } - async queueGrouplikeItem(topItem, afterItem = null) { + async queueGrouplikeItem(topItem, afterItem = null, {movePlayingTrack = true} = {}) { const newTrackIndex = this.queueGrouplike.items.length const recursivelyAddTracks = item => { @@ -458,6 +460,12 @@ class AppElement extends FocusElement { // is needed to fix the display, but then you end up with a new object // that doesn't work with indexOf).) if (items.includes(item)) { + // HOWEVER, if the "moveCurrentTrack" option is false, and that item + // is the one that's currently playing, we won't do anything with it + // at all. + if (!movePlayingTrack && item === this.playingTrack) { + return + } items.splice(items.indexOf(item), 1) } -- cgit 1.3.0-6-gf8a5