diff options
Diffstat (limited to 'src/pickers.js')
-rw-r--r-- | src/pickers.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/pickers.js b/src/pickers.js index ee886bc..2f44630 100644 --- a/src/pickers.js +++ b/src/pickers.js @@ -27,9 +27,13 @@ function makeShufflePlaylistPicker(grouplike) { const flatGroup = flattenGrouplike(grouplike) return function() { - const index = Math.floor(Math.random() * flatGroup.items.length) - const picked = flatGroup.items[index] - return picked + if (flatGroup.items.length) { + const index = Math.floor(Math.random() * flatGroup.items.length) + const picked = flatGroup.items[index] + return picked + } else { + return null + } } } |