« get me outta code hell

queue sorting fixes re: selected track - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <towerofnix@gmail.com>2021-03-15 20:35:31 -0300
committer(quasar) nebula <towerofnix@gmail.com>2021-03-15 20:35:31 -0300
commitc542bc1a2acca7c62f9556499945794878789e3e (patch)
tree173092a310123c3e45748d1e9e18e611b3b806e8
parent1fb903a227094b5995d807f7bfc1c3bb414b37e5 (diff)
queue sorting fixes re: selected track
not 100% sure what these are for since i wrote this patch ages ago!
sorry :3
-rw-r--r--ui.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/ui.js b/ui.js
index 8945ce0..20cfd99 100644
--- a/ui.js
+++ b/ui.js
@@ -1583,14 +1583,15 @@ class AppElement extends FocusElement {
     }
 
     if (where === 'next' || where === 'after-selected' || where === 'before-selected' || where === 'end') {
+      const selected = this.queueListingElement.currentItem
       let afterItem = null
       if (where === 'next') {
         afterItem = playingTrack
       } else if (where === 'after-selected') {
-        afterItem = this.queueListingElement.currentItem
+        afterItem = selected
       } else if (where === 'before-selected') {
         const { items } = this.SQP.queueGrouplike
-        const index = items.indexOf(this.queueListingElement.currentItem)
+        const index = items.indexOf(selected)
         if (index === 0) {
           afterItem = 'FRONT'
         } else if (index > 0) {
@@ -1599,11 +1600,13 @@ class AppElement extends FocusElement {
       }
 
       this.SQP.queue(item, afterItem, {
-        movePlayingTrack: order === 'normal'
+        movePlayingTrack: order === 'normal' || order === 'alphabetic'
       })
 
       if (isTrack(passedItem)) {
         this.queueListingElement.selectAndShow(passedItem)
+      } else {
+        this.queueListingElement.selectAndShow(selected)
       }
     } else if (where.startsWith('distribute-')) {
       this.SQP.distributeQueue(item, {