« get me outta code hell

Show duration of selected item in context menu - 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:
authorFlorrie <towerofnix@gmail.com>2019-08-08 20:07:55 -0300
committerFlorrie <towerofnix@gmail.com>2019-08-08 20:07:55 -0300
commit577514bbf1a2a92187fa8ab93b696c4ca6ba1167 (patch)
tree40661cf0d596fdd344a406f8aab7d611864ed6cd /ui.js
parentf0e6dd7283b3825d8ded273179ba113924605979 (diff)
Show duration of selected item in context menu
This takes the place of the number of direct children items (opting to
show just the total number of tracks).
Diffstat (limited to 'ui.js')
-rw-r--r--ui.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/ui.js b/ui.js
index fa29fd6..a02c85f 100644
--- a/ui.js
+++ b/ui.js
@@ -587,14 +587,16 @@ class AppElement extends FocusElement {
         canControlQueue && {label: 'Remove from queue', action: () => this.unqueue(item)}
       ]
     } else {
+      const numTracks = countTotalItems(item)
+      const { string: durationString } = this.backend.getDuration(item)
       items = [
         // A label that just shows some brief information about the item.
         {label:
           `(${item.name ? `"${item.name}"` : 'Unnamed'}` +
           (isGroup(item) ? (
             ' -' +
-            ` ${item.items.length} item${item.items.length === 1 ? '' : 's'}` +
-            `, ${countTotalItems(item)} total`)
+            ` ${numTracks} track${numTracks === 1 ? '' : 's'}` +
+            `, ${durationString}`)
           : '') + ')',
           keyboardIdentifier: item.name
         },