« get me outta code hell

mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ui.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/ui.js b/ui.js
index e837256..7056506 100644
--- a/ui.js
+++ b/ui.js
@@ -206,6 +206,7 @@ class AppElement extends FocusElement {
 
     this.whereControl = new InlineListPickerElement('Where?', [
       {value: 'next', label: 'After current song'},
+      {value: 'next-selected', label: 'After selected song'},
       {value: 'end', label: 'At end of queue'},
       {value: 'distribute-evenly', label: 'Distributed across queue evenly'},
       {value: 'distribute-randomly', label: 'Distributed across queue randomly'}
@@ -769,6 +770,8 @@ class AppElement extends FocusElement {
   // just directly moved from the old event listener on grouplikeListings for
   // 'queue'.
   handleQueueOptions(item, {where = 'end', order = 'normal', play = false, skip = false} = {}) {
+    const passedItem = item
+
     if (skip && this.playingTrack === item) {
       this.playNextTrack(this.playingTrack)
     }
@@ -784,15 +787,21 @@ class AppElement extends FocusElement {
       item = {items: [item]}
     }
 
-    if (where === 'next' || where === 'end') {
+    if (where === 'next' || where === 'next-selected' || where === 'end') {
       let afterItem = null
       if (where === 'next') {
         afterItem = this.playingTrack
+      } else if (where === 'next-selected') {
+        afterItem = this.queueListingElement.currentItem
       }
 
       this.queueGrouplikeItem(item, afterItem, {
         movePlayingTrack: order === 'normal'
       })
+
+      if (isTrack(passedItem)) {
+        this.queueListingElement.selectAndShow(passedItem)
+      }
     } else if (where.startsWith('distribute-')) {
       this.distributeQueueGrouplikeItem(item, {
         how: where.slice('distribute-'.length)