« get me outta code hell

mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ui.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/ui.js b/ui.js
index df8d914..1331344 100644
--- a/ui.js
+++ b/ui.js
@@ -1257,7 +1257,9 @@ class AppElement extends FocusElement {
       if (qp.timeData) {
         let effectiveCurSec = qp.timeData.curSecTotal
 
-        const ts = this.getTimestampAtSec(qp.playingTrack, qp.timeData.curSecTotal)
+        const ts = (qp.timeData &&
+          this.getTimestampAtSec(qp.playingTrack, qp.timeData.curSecTotal))
+
         if (ts) {
           effectiveCurSec -= ts.timestamp
         }
@@ -1280,7 +1282,9 @@ class AppElement extends FocusElement {
         return
       }
 
-      const ts = this.getTimestampAtSec(qp.playingTrack, qp.timeData.curSecTotal)
+      const ts = (qp.timeData &&
+        this.getTimestampAtSec(qp.playingTrack, qp.timeData.curSecTotal))
+
       if (ts) {
         qp.seekTo(ts.timestamp)
         return
@@ -1296,7 +1300,9 @@ class AppElement extends FocusElement {
         return
       }
 
-      const ts = this.getTimestampAtSec(qp.playingTrack, qp.timeData.curSecTotal)
+      const ts = (qp.timeData &&
+        this.getTimestampAtSec(qp.playingTrack, qp.timeData.curSecTotal))
+
       if (ts) {
         const timestampData = this.getTimestampData(qp.playingTrack)
         const playingTimestampIndex = timestampData.indexOf(ts)
@@ -1317,7 +1323,8 @@ class AppElement extends FocusElement {
         return
       }
 
-      const ts = this.getTimestampAtSec(qp.playingTrack, qp.timeData.curSecTotal)
+      const ts = (qp.timeData &&
+        this.getTimestampAtSec(qp.playingTrack, qp.timeData.curSecTotal))
 
       if (ts) {
         const timestampData = this.getTimestampData(qp.playingTrack)