« get me outta code hell

Don't reload the listing if it's unnecessary - 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>2019-09-18 17:56:11 -0300
committerFlorrie <towerofnix@gmail.com>2019-09-18 17:56:11 -0300
commita5d3b710eb46e58708b8dbb51f5231ba534561fd (patch)
treec61d94a89751c45dad51d0248c45386017b91d59
parent43f5b514ed0bd2afcf887b830bc9ad42651f7d28 (diff)
Don't reload the listing if it's unnecessary
...in reveal(). This fixes the bug where the revealed track would always
be positioned at the bottom of the screen, which happened because
reloading the listing reset the scroll index back to the top.
-rw-r--r--todo.txt7
-rw-r--r--ui.js8
2 files changed, 13 insertions, 2 deletions
diff --git a/todo.txt b/todo.txt
index 161d7f9..3470204 100644
--- a/todo.txt
+++ b/todo.txt
@@ -384,6 +384,7 @@ TODO: Revealing a track shouldn't forcibly position it at the bottom of the
       if the item is already visible, and if it's above the current scroll
       area, make it appear at the top of the listing view instead of the
       bottom.
+      (Done!)
 
 TODO: Text file support. Yes. Heck yes. Heck hecking yes.
       Read text files contained in your music library folders. If there is a
@@ -396,3 +397,9 @@ TODO: Make 'after selected song' the default in the context menu, too. I miight
       general, and if you prefer 'after current song', that option isn't hard
       to discover and select.
       (Done!)
+
+TODO: Investigate why reveal() has distinct support for grouplikes as well as
+      tracks - you can't append actual groups to the queue (only their
+      flattened children) after all. But if you could -- I think reveal should
+      work the same for groups as it does for tracks, i.e. opening the parent
+      and then selecting the item.
diff --git a/ui.js b/ui.js
index 7ef13f0..aafe064 100644
--- a/ui.js
+++ b/ui.js
@@ -513,10 +513,14 @@ class AppElement extends FocusElement {
 
     const tabberListing = this.tabber.currentElement
     this.root.select(tabberListing)
+
+    const parent = item[parentSymbol]
     if (isGroup(item)) {
       tabberListing.loadGrouplike(item)
-    } else if (item[parentSymbol]) {
-      tabberListing.loadGrouplike(item[parentSymbol])
+    } else if (parent) {
+      if (tabberListing.grouplike !== parent) {
+        tabberListing.loadGrouplike(parent)
+      }
       tabberListing.selectAndShow(item)
     }
   }