From a7288adf4c5ae3e1bc4f048e6ab55054fee59d8f Mon Sep 17 00:00:00 2001 From: Rafostar <40623528+Rafostar@users.noreply.github.com> Date: Sat, 1 May 2021 12:27:56 +0200 Subject: [PATCH] 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 --- src/playlist.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/playlist.js b/src/playlist.js index c6265e7b..d42ce083 100644 --- a/src/playlist.js +++ b/src/playlist.js @@ -192,20 +192,14 @@ class ClapperPlaylistWidget extends Gtk.ListBox index++; } - if(playlistIds.length) { - const randomId = playlistIds[ - Math.floor(Math.random() * playlistIds.length) - ]; - debug(`selected random playlist item: ${randomId}`); + /* We always have non-empty array here, + * otherwise seek to beginning is performed */ + const randomId = playlistIds[ + Math.floor(Math.random() * playlistIds.length) + ]; + debug(`selected random playlist item: ${randomId}`); - return this.changeActiveRow(randomId); - } - else { - debug('only one playlist item, playing again'); - - player.seek(0); - return true; - } + return this.changeActiveRow(randomId); } if(this.nextTrack())