« get me outta code hell

prepare to view selected items page after starting selection - 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 <qznebula@protonmail.com>2024-05-14 17:42:59 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-05-14 17:42:59 -0300
commit778a6961cc1cca9d6649d3ff38206f6f5e9e929a (patch)
treea76806caea07c1a51bd2602f4d22b36a6357d10e
parent180df0db0904ac8a0fd4070d0f2f320358d04a88 (diff)
prepare to view selected items page after starting selection
This was the intended behavior from the start! We just forgot to
code this part, oops.
-rw-r--r--ui.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/ui.js b/ui.js
index 3d66ce8..b784688 100644
--- a/ui.js
+++ b/ui.js
@@ -971,6 +971,13 @@ export default class AppElement extends FocusElement {
       return
     }
 
+    // If this is the first addition (starting from empty), switch the
+    // remembered context menu page so that the next context menu will show
+    // the marked items automatically.
+    if (!mark.length) {
+      this.itemMenuPage = 'mark'
+    }
+
     for (const track of add) {
       mark.push(track)
     }
@@ -998,6 +1005,15 @@ export default class AppElement extends FocusElement {
       mark.splice(mark.indexOf(track), 1)
     }
 
+    // If this is the last removal (going to empty), switch the remembered
+    // context menu page so that the next context menu will show the usual
+    // controls for the item under the cursor. This isn't exactly necessary
+    // since various fallbacks will handle this value pointing to a page that
+    // doesn't exist anymore, but it's nice for consistency.
+    if (!mark.length) {
+      this.itemMenuPage = 'cursor'
+    }
+
     this.emitMarkChanged()
   }