« get me outta code hell

Fix path element not working in queue listing - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2018-08-15 16:36:02 -0300
committerFlorrie <towerofnix@gmail.com>2018-08-15 16:36:02 -0300
commitc40b45efc43f83a301531e9e0d239eaf98351f5f (patch)
treec06f183dc26a786b481dec470ba9dde1fd4c2e08
parentc9cebea24ab42b42d5fdf2f43caa5a056d0602d1 (diff)
Fix path element not working in queue listing
-rw-r--r--ui.js20
1 files changed, 15 insertions, 5 deletions
diff --git a/ui.js b/ui.js
index 0314fba..befa764 100644
--- a/ui.js
+++ b/ui.js
@@ -53,6 +53,7 @@ class AppElement extends FocusElement {
     this.newGrouplikeListing()
 
     this.queueListingElement = new QueueListingElement(this.recordStore)
+    this.setupCommonGrouplikeListingEvents(this.queueListingElement)
     this.queueListingElement.loadGrouplike(this.queueGrouplike)
     this.paneRight.addChild(this.queueListingElement)
 
@@ -203,19 +204,28 @@ class AppElement extends FocusElement {
       }
     })
 
+    this.setupCommonGrouplikeListingEvents(grouplikeListing)
+
+    return grouplikeListing
+  }
+
+  setupCommonGrouplikeListingEvents(grouplikeListing) {
+    // Sets up event listeners that are common to ordinary grouplike listings
+    // (made by newGrouplikeListing) as well as the queue grouplike listing.
+
     const handleSelectFromPathElement = item => {
-      this.root.select(grouplikeListing)
+      const tabberListing = this.tabber.currentElement
+      this.root.select(tabberListing)
       if (isGroup(item)) {
-        grouplikeListing.loadGrouplike(item)
+        tabberListing.loadGrouplike(item)
       } else if (item[parentSymbol]) {
-        grouplikeListing.loadGrouplike(item[parentSymbol])
-        grouplikeListing.selectAndShow(item)
+        tabberListing.loadGrouplike(item[parentSymbol])
+        tabberListing.selectAndShow(item)
       }
     }
 
     grouplikeListing.pathElement.on('select', item => handleSelectFromPathElement(item))
 
-    return grouplikeListing
   }
 
   async handlePlaylistSource(source, newTab = false) {