Fixed reset on non-empty queue

Fixed an issue where reset didn't work when the queue had any tracks in
it. The issue stemmed from the fact that in the last few lines of the
PlayCurrent method in the queue.go, around line 314, it sets up another
thread to wait and eventually skip the current track. When reset is
called this skip is triggered on an empty queue which causes an error.
Fixed it by adding a check around the offending lines.
This commit is contained in:
Jason Waataja 2018-07-20 17:19:19 -07:00
parent a57c3f579d
commit 6e76c79e0a

View file

@ -211,6 +211,7 @@ func (q *Queue) Skip() {
}
// Remove all playlist skips if this is the last track of the playlist still in the queue.
if len(q.Queue) > 0 {
if playlist := q.Queue[0].GetPlaylist(); playlist != nil {
id := playlist.GetID()
playlistIsFinished := true
@ -229,6 +230,7 @@ func (q *Queue) Skip() {
DJ.Skips.ResetPlaylistSkips()
}
}
}
// Skip the track.
length := len(q.Queue)