« get me outta code hell

Fix shift-up/down crash when not playing anything - 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-06-03 19:24:21 -0300
committerFlorrie <towerofnix@gmail.com>2018-06-03 19:24:21 -0300
commit4fbcb453bbbc84feabf1ed45c93ead749bf59ef5 (patch)
tree402374aa6b94ed77014b4f37f16125dac3f44358
parente13e4d57302cab12af7e43b431052cc3d2d32e9a (diff)
Fix shift-up/down crash when not playing anything
-rw-r--r--ui.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/ui.js b/ui.js
index 02c77bb..8e235a0 100644
--- a/ui.js
+++ b/ui.js
@@ -252,6 +252,10 @@ class AppElement extends FocusElement {
   }
 
   playNextTrack(track) {
+    if (!track) {
+      return
+    }
+
     const queue = this.queueGrouplike
     let queueIndex = queue.items.indexOf(track)
     if (queueIndex === -1) {
@@ -277,6 +281,10 @@ class AppElement extends FocusElement {
   }
 
   playPreviousTrack(track) {
+    if (!track) {
+      return
+    }
+
     const queue = this.queueGrouplike
     let queueIndex = queue.items.indexOf(track)
     if (queueIndex === -1) {