Volumio2 icon indicating copy to clipboard operation
Volumio2 copied to clipboard

repeatSingle status gets out of sync within pushState event

Open Joni-Salminen opened this issue 3 years ago • 0 comments

This happens when Repeat single track is enabled, and Repeat is disabled without providing repeatSingle argument. I believe this could be overcome by not nesting repeatSingle check inside repeat check. this would also make the repeatSingle status reflect the actual player status in every scenario.

repeat == false, repeatSingle = false -> Repeat is not enabled repeat == true, repeatSingle = false -> Repeat is enabled repeat == true, repeatSingle = true-> Repeat single is enabled repeat == false, repeatSingle = true -> Repeat is not enabled

I'm not familiar with javascript, but if i'm looking into a correct place this is where we decide next track

CoreStateMachine.prototype.getNextIndex = function () {
  var nextIndex = this.currentPosition + 1;

  var isLastTrack = (this.playQueue.arrayQueue.length - 1) == this.currentPosition;

  // Check if Repeat mode is on and last track is played, note that Random and Consume overrides Repeat
  if (this.currentRepeat) {
    if (this.currentRepeatSingleSong) {
      nextIndex = this.currentPosition;
    } else if (isLastTrack) {
      nextIndex = 0;
    }
  }

but i believe it could be rearranged like so, then the repeatSingle worked always if it was enabled.

  if(this.currentRepeatSingleSong) {
      nextIndex = this.currentPosition;
  } 
  else if (this.currentRepeat && isLastTrack) {
	nextIndex = 0;
  }

Edit: put the code on blocks

Joni-Salminen avatar May 06 '21 18:05 Joni-Salminen