« get me outta code hell

mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/ui.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui.js')
-rw-r--r--ui.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/ui.js b/ui.js
index 175bf73..6f8b07a 100644
--- a/ui.js
+++ b/ui.js
@@ -1,7 +1,7 @@
 const { getAllCrawlersForArg } = require('./crawlers')
 const { getDownloaderFor } = require('./downloaders')
 const { getPlayer } = require('./players')
-const { parentSymbol, isGroup, isTrack, getItemPath, getItemPathString, flattenGrouplike, countTotalItems, cloneGrouplike } = require('./playlist-utils')
+const { parentSymbol, isGroup, isTrack, getItemPath, getItemPathString, flattenGrouplike, countTotalItems, shuffleOrderOfGroups, cloneGrouplike } = require('./playlist-utils')
 const { shuffleArray } = require('./general-util')
 const processSmartPlaylist = require('./smart-playlist')
 const UndoManager = require('./undo-manager')
@@ -110,8 +110,12 @@ class AppElement extends FocusElement {
     grouplikeListing.on('menu', (item, opts) => this.menu.show(opts))
 
     grouplikeListing.on('queue', (item, {where = 'end', order = 'normal', play = false} = {}) => {
-      if (isGroup(item) && order === 'shuffle') {
-        item = {items: shuffleArray(flattenGrouplike(item).items)}
+      if (isGroup(item)) {
+        if (order === 'shuffle') {
+          item = {items: shuffleArray(flattenGrouplike(item).items)}
+        } else if (order === 'shuffle-groups') {
+          item = shuffleOrderOfGroups(item)
+        }
       }
 
       let afterItem = null
@@ -1177,7 +1181,8 @@ class InteractiveGrouplikeItemElement extends BasicGrouplikeItemElement {
     ])
 
     this.orderControl = new InlineListPickerElement('Order?', [
-      {value: 'shuffle', label: 'Shuffle'},
+      {value: 'shuffle', label: 'Shuffle all'},
+      {value: 'shuffle-groups', label: 'Shuffle order of groups'},
       {value: 'normal', label: 'In order'}
     ])
   }