« get me outta code hell

'Remove from queue' menu option - 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-20 10:16:01 -0300
committerFlorrie <towerofnix@gmail.com>2018-08-20 10:16:01 -0300
commitef10e1b16f9d79789cdbc8f60a1aa71854d8f762 (patch)
treeda86519e2cf672760264e75b56377b53547812fa
parentb5980abf5df2a36c59db35163c129f5b1423c4a2 (diff)
'Remove from queue' menu option
-rw-r--r--todo.txt8
-rw-r--r--ui.js15
2 files changed, 16 insertions, 7 deletions
diff --git a/todo.txt b/todo.txt
index 5cc064f..25c8369 100644
--- a/todo.txt
+++ b/todo.txt
@@ -109,3 +109,11 @@ TODO: Make the queue code more sane.
 TODO: Figure out when the "queue" context menu options should immediately play
       the track. Currently, they don't ever initiate playing (besides the
       "Play now" option).
+
+TODO: A "remove from queue" option for tracks and groups, which removes them
+      and their children from the queue.
+      (Done!)
+
+TODO: After the end of a shuffled queue, the next song from the group of the
+      last track is played (and so on, until the group is empty). This seems
+      definitely wrong.
diff --git a/ui.js b/ui.js
index ac7154d..9154390 100644
--- a/ui.js
+++ b/ui.js
@@ -122,6 +122,8 @@ class AppElement extends FocusElement {
       }
     })
 
+    grouplikeListing.on('unqueue', item => this.unqueueGrouplikeItem(item))
+
     const updateListingsFor = item => {
       for (const grouplikeListing of this.tabber.tabberElements) {
         if (grouplikeListing.grouplike === item) {
@@ -475,11 +477,9 @@ class AppElement extends FocusElement {
   }
 
   unqueueGrouplikeItem(topItem) {
-    // This function has support to unqueue groups (it removes all tracks in
-    // the group recursively), but there's no UI for that yet. That is, there
-    // isn't a key to unqueue an item from the main listing. (You can never
-    // unqueue a group from the queue listing because groups can't be added
-    // directly to the queue.)
+    // This function has support to unqueue groups - it removes all tracks in
+    // the group recursively. (You can never unqueue a group itself from the
+    // queue listing because groups can't be added directly to the queue.)
 
     const recursivelyUnqueueTracks = item => {
       // For groups, just unqueue all children. (Groups themselves can't be
@@ -788,7 +788,7 @@ class GrouplikeListingElement extends Form {
     }
 
     for (const itemElement of itemElements) {
-      for (const evtName of ['download', 'remove', 'mark', 'paste', 'browse', 'queue', 'menu']) {
+      for (const evtName of ['download', 'remove', 'mark', 'paste', 'browse', 'queue', 'unqueue', 'menu']) {
         itemElement.on(evtName, (...data) => this.emit(evtName, itemElement.item, ...data))
       }
       form.addInput(itemElement)
@@ -990,7 +990,8 @@ class GrouplikeItemElement extends Button {
           this.isReal && {label: 'Play next', action: () => this.emit('queue', {where: 'next'})},
           this.isReal && {label: 'Play at end', action: () => this.emit('queue', {where: 'end'})},
           this.isGroup && {label: 'Play next, shuffled', action: () => this.emit('queue', {where: 'next', shuffle: true})},
-          this.isGroup && {label: 'Play at end, shuffled', action: () => this.emit('queue', {where: 'end', shuffle: true})}
+          this.isGroup && {label: 'Play at end, shuffled', action: () => this.emit('queue', {where: 'end', shuffle: true})},
+          this.isReal && {label: 'Remove from queue', action: () => this.emit('unqueue')}
         ]
       })
     }