« 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--todo.txt1
-rw-r--r--ui.js26
2 files changed, 15 insertions, 12 deletions
diff --git a/todo.txt b/todo.txt
index 531accf..fc21476 100644
--- a/todo.txt
+++ b/todo.txt
@@ -240,3 +240,4 @@ TODO: An indicator for the number of tracks in the queue!
       (Done!)
 
 TODO: "Reveal" option in queue listing context menu.
+      (Done!)
diff --git a/ui.js b/ui.js
index 1457923..071714e 100644
--- a/ui.js
+++ b/ui.js
@@ -318,21 +318,21 @@ class AppElement extends FocusElement {
     // Sets up event listeners that are common to ordinary grouplike listings
     // (made by newGrouplikeListing) as well as the queue grouplike listing.
 
-    const handleSelectFromPathElement = item => {
-      const tabberListing = this.tabber.currentElement
-      this.root.select(tabberListing)
-      if (isGroup(item)) {
-        tabberListing.loadGrouplike(item)
-      } else if (item[parentSymbol]) {
-        tabberListing.loadGrouplike(item[parentSymbol])
-        tabberListing.selectAndShow(item)
-      }
-    }
-
-    grouplikeListing.pathElement.on('select', item => handleSelectFromPathElement(item))
+    grouplikeListing.pathElement.on('select', item => this.reveal(item))
     grouplikeListing.on('menu', (item, el) => this.showMenuForItemElement(el, grouplikeListing))
   }
 
+  reveal(item) {
+    const tabberListing = this.tabber.currentElement
+    this.root.select(tabberListing)
+    if (isGroup(item)) {
+      tabberListing.loadGrouplike(item)
+    } else if (item[parentSymbol]) {
+      tabberListing.loadGrouplike(item[parentSymbol])
+      tabberListing.selectAndShow(item)
+    }
+  }
+
   showMenuForItemElement(el, listing) {
     const emitControls = play => () => {
       this.handleQueueOptions(item, {
@@ -349,6 +349,8 @@ class AppElement extends FocusElement {
     let items;
     if (listing.grouplike.isTheQueue) {
       items = [
+        {label: 'Reveal', action: () => this.reveal(item)},
+        {divider: true},
         {label: 'Play later', action: () => this.handleQueueOptions(item, {
           where: 'distribute-randomly',
           skip: true