From 764a2330d9271777a06b0ac8ca4bc979d11f52d2 Mon Sep 17 00:00:00 2001 From: William Toohey Date: Sat, 6 Feb 2016 16:35:42 +1000 Subject: [PATCH] Fix manually set songs not clearing random buffer --- src/js/HuesCore.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/js/HuesCore.js b/src/js/HuesCore.js index 2dd4be1..7c19273 100644 --- a/src/js/HuesCore.js +++ b/src/js/HuesCore.js @@ -342,13 +342,11 @@ HuesCore.prototype.blurUpdated = function(x, y) { }; HuesCore.prototype.nextSong = function() { - this.lastSongArray = []; let index = (this.songIndex + 1) % this.resourceManager.enabledSongs.length; this.setSong(index); }; HuesCore.prototype.previousSong = function() { - this.lastSongArray = []; let index = ((this.songIndex - 1) + this.resourceManager.enabledSongs.length) % this.resourceManager.enabledSongs.length; this.setSong(index); }; @@ -372,10 +370,14 @@ HuesCore.prototype.setSongOject = function(song) { } }; -HuesCore.prototype.setSong = function(index) { +HuesCore.prototype.setSong = function(index, leaveArray) { if(this.currentSong == this.resourceManager.enabledSongs[index]) { return; } + // When not randoming, clear this + if(!leaveArray) { + this.lastSongArray = []; + } this.lastSongArray.push(index); this.songIndex = index; this.currentSong = this.resourceManager.enabledSongs[this.songIndex]; @@ -461,7 +463,7 @@ HuesCore.prototype.randomSong = function() { this.randomSong(); } else { console.log("Randoming a song!"); - this.setSong(index); + this.setSong(index, true); let noRepeat = Math.min(5, Math.floor(songCount / 2)); while (this.lastSongArray.length > noRepeat && noRepeat >= 0) { this.lastSongArray.shift();