« get me outta code hell

mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/ui.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui.js')
-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) {