Volumio2 icon indicating copy to clipboard operation
Volumio2 copied to clipboard

moveQueue {from:N,to:N2} command is not working when N (from) is equal to zero

Open ghost opened this issue 3 years ago • 5 comments

Using the command moveQueue {from:N,to:N2} it will not work (not move the song) if the song to be moved is at position 0. So the first song of the queue can never be moved!

ghost avatar Mar 25 '21 08:03 ghost

I believe the issue is here, and the debug log in volumio/dev kinda confirms it since the error seen in the function is placed in the log if parameters "to" or "from" is equal to zero, so the the if clause evaluates as false.

this could be worked around by null checking the values instead of checking if the values are >= 1, which propably was not the intention here.

  var defer = libQ.defer();
  this.pushConsoleMessage('CoreCommandRouter::volumioMoveQueue');

  if (from && to) { <-- here 0 == false, so we don't proceed
    return this.stateMachine.moveQueueItem(from, to);
  } else {
    this.logger.error('Cannot move item in queue, from or to parameter missing');
    var queueArray = this.stateMachine.getQueue();
    defer.resolve(queueArray);
    return defer.promise;
  }
};```

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

Or just check: if (from>=0 && to>=0)

ghost avatar May 06 '21 19:05 ghost

that does not guard against uninitialised variables or null variables thought, i dont know im not javascript guy. anyway i did make a pull request to get it fixed, hopefully i got correct in there.

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

Thanks Joni!

ghost avatar May 06 '21 19:05 ghost

FTR the PR is #2116

xipmix avatar May 18 '21 12:05 xipmix