« get me outta code hell

show timestamp hours column whenever appropriate - 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:
author(quasar) nebula <towerofnix@gmail.com>2021-08-14 00:44:47 -0300
committer(quasar) nebula <towerofnix@gmail.com>2021-08-14 00:44:47 -0300
commit39732bd31e13c9a785eac1fc724bc9fc768be2ab (patch)
tree2a40a9227f65832a202706cf2e9a1132e4024cd7 /ui.js
parentc047b8c57d4e5012578c072420d2b73dd5b59c4c (diff)
show timestamp hours column whenever appropriate
Diffstat (limited to 'ui.js')
-rw-r--r--ui.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/ui.js b/ui.js
index 2da7e02..d6452d9 100644
--- a/ui.js
+++ b/ui.js
@@ -2557,7 +2557,7 @@ class GrouplikeListingElement extends Form {
       // Generate some items! Just go over the data list and generate one for
       // each timestamp.
       const tsElements = timestampData.map(ts => {
-        const el = new TimestampGrouplikeItemElement(item, ts, this.app)
+        const el = new TimestampGrouplikeItemElement(item, ts, timestampData, this.app)
         el.on('pressed', () => this.emit('timestamp', item, ts.timestamp))
         if (this.grouplike.isTheQueue) {
           el.hideMetadata = true
@@ -3752,20 +3752,24 @@ class InteractiveGrouplikeItemElement extends BasicGrouplikeItemElement {
 }
 
 class TimestampGrouplikeItemElement extends BasicGrouplikeItemElement {
-  constructor(item, timestampData, app) {
+  constructor(item, timestampData, tsDataArray, app) {
     super('')
 
     this.app = app
     this.data = timestampData
+    this.tsData = tsDataArray
     this.item = item
     this.hideMetadata = false
   }
 
   drawTo(writable) {
-    const { data } = this
+    const { data, tsData } = this
 
     const metadata = this.app.backend.getMetadataFor(this.item)
-    const duration = (metadata && metadata.duration) || 0
+    const last = tsData[tsData.length - 1]
+    const duration = ((metadata && metadata.duration)
+      || last.timestampEnd !== Infinity && last.timestampEnd
+      || last.timestamp)
     const strings = getTimeStringsFromSec(data.timestamp, duration)
     const stringsEnd = getTimeStringsFromSec(data.timestampEnd, duration)