Do not check Ids length in shuffle repeat mode

We always have at least 2 playlist items, thus at least 1 Id in array when we reach this point in code
This commit is contained in:
Rafostar
2021-05-01 12:27:56 +02:00
parent 9bb3f999b1
commit a7288adf4c

View File

@@ -192,20 +192,14 @@ class ClapperPlaylistWidget extends Gtk.ListBox
index++; index++;
} }
if(playlistIds.length) { /* We always have non-empty array here,
const randomId = playlistIds[ * otherwise seek to beginning is performed */
Math.floor(Math.random() * playlistIds.length) const randomId = playlistIds[
]; Math.floor(Math.random() * playlistIds.length)
debug(`selected random playlist item: ${randomId}`); ];
debug(`selected random playlist item: ${randomId}`);
return this.changeActiveRow(randomId); return this.changeActiveRow(randomId);
}
else {
debug('only one playlist item, playing again');
player.seek(0);
return true;
}
} }
if(this.nextTrack()) if(this.nextTrack())