From 2358a551b556463efffcfe66386972f56eb6d3d7 Mon Sep 17 00:00:00 2001
From: Eliot Berriot <contact@eliotberriot.com>
Date: Wed, 14 Jun 2017 20:16:18 +0200
Subject: [PATCH] Will now play appended track automatically if end of queue
 was previously reached

---
 src/audio/queue.js | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/audio/queue.js b/src/audio/queue.js
index 694567a..ac04e0f 100644
--- a/src/audio/queue.js
+++ b/src/audio/queue.js
@@ -11,6 +11,7 @@ class Queue {
     this.tracks = []
     this.currentIndex = -1
     this.currentTrack = null
+    this.ended = true
     this.state = {
       volume: cache.get('volume', 0.5)
     }
@@ -98,8 +99,8 @@ class Queue {
       // we insert the track at given position
       this.tracks.splice(index, 0, track)
     }
-    if (this.currentIndex < 0) {
-      this.play(0)
+    if (this.ended) {
+      this.play(this.currentIndex + 1)
     }
     this.cache()
   }
@@ -154,6 +155,7 @@ class Queue {
     }
     this.currentIndex = index
     this.currentTrack = this.tracks[index]
+    this.ended = false
     let file = this.currentTrack.files[0]
     if (!file) {
       return this.next()
@@ -178,6 +180,7 @@ class Queue {
       this.next()
     } else {
       logger.default.info('We reached the end of the queue')
+      this.ended = true
     }
   }
 
-- 
GitLab