« get me outta code hell

Tie in delete-up-next a little nicer - http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2017-09-02 11:52:59 -0300
committerFlorrie <towerofnix@gmail.com>2017-09-02 11:52:59 -0300
commit2efec475218b90411d92688b5d69247571340a96 (patch)
tree27e22ca697b7bb3f02efe98e0860577faa568b9e
parent5d56a8f04fb08a1754d375a222aaf05d16950ca1 (diff)
Tie in delete-up-next a little nicer
-rw-r--r--src/loop-play.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/loop-play.js b/src/loop-play.js
index c95c1c4..24134b0 100644
--- a/src/loop-play.js
+++ b/src/loop-play.js
@@ -350,10 +350,12 @@ class PlayController extends EventEmitter {
     })
   }
 
-  startNextDownload() {
+  startNextDownload(moveTimelineIndex = true) {
     this.isDownloading = true
 
-    const picked = this.historyController.getNextTrack()
+    const picked = (moveTimelineIndex
+      ? this.historyController.getNextTrack()
+      : this.historyController.currentTrack)
     this.nextTrack = picked
 
     if (!picked) {
@@ -413,8 +415,13 @@ class PlayController extends EventEmitter {
       await safeUnlink(this.nextFile, this.playlist)
     }
 
+    // The timeline is always one index ahead.
+    const tl = this.historyController.timeline
+    tl.splice(this.historyController.timelineIndex - 1, 1)
+    this.historyController.fillTimeline()
+
     this.downloadController.cancel()
-    return this.startNextDownload()
+    return this.startNextDownload(false)
   }
 
   async stop() {