« get me outta code hell

fix playOrSeek messing with queue order - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/backend.js
diff options
context:
space:
mode:
author(quasar) nebula <towerofnix@gmail.com>2021-07-17 20:37:08 -0300
committer(quasar) nebula <towerofnix@gmail.com>2021-07-17 20:37:08 -0300
commita55e2dda6b7cd2e413445964f44a98a8a07058a7 (patch)
treec1ae453601f93937329ef415bc052200d7f26b97 /backend.js
parentee9ba81c076b7986e8fe752b3badbc6a8b7aec50 (diff)
fix playOrSeek messing with queue order
Diffstat (limited to 'backend.js')
-rw-r--r--backend.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/backend.js b/backend.js
index 51419da..e2213d5 100644
--- a/backend.js
+++ b/backend.js
@@ -511,10 +511,22 @@ class QueuePlayer extends EventEmitter {
   }
 
   async playOrSeek(item, time) {
+    if (!isTrack(item)) {
+      // This only makes sense to call with individual tracks!
+      return
+    }
+
     if (item === this.playingTrack) {
       this.seekTo(time)
     } else {
-      this.queue(item, this.playingTrack)
+      // Queue the track, but only if it's not already in the queue, so that we
+      // respect an existing queue order.
+      const queue = this.queueGrouplike
+      const queueIndex = queue.items.indexOf(item)
+      if (queueIndex === -1) {
+        this.queue(item, this.playingTrack)
+      }
+
       this.play(item, time)
     }
   }