diff options
author | Florrie <towerofnix@gmail.com> | 2018-06-01 17:59:27 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2018-06-01 17:59:27 -0300 |
commit | c283c559c777eab7a533a38a646607a91e98bd6f (patch) | |
tree | 8fffe040476522b07d84f5d038d41a3b6810c664 | |
parent | b49395ccf3cf87dadc01fd4ba49ebdbda4cb15d4 (diff) |
Only call buildItems once when a group is queued
-rw-r--r-- | todo.txt | 3 | ||||
-rw-r--r-- | ui.js | 13 |
2 files changed, 7 insertions, 9 deletions
diff --git a/todo.txt b/todo.txt index 58b25f9..ca43148 100644 --- a/todo.txt +++ b/todo.txt @@ -6,8 +6,5 @@ TODO: A "shuffle queue" button! TODO: A "clear queue" button. -TODO: Don't immediately queue an entire group if it has more than 100 items - - ask first. - TODO: A way to jump to an item with a particular name. Probably press "/". It'd be nice if the closest match got highlighted while you were typing. diff --git a/ui.js b/ui.js index 778f5eb..0c2be5f 100644 --- a/ui.js +++ b/ui.js @@ -117,17 +117,17 @@ class AppElement extends FocusElement { this.player.togglePause() } - async queueGrouplikeItem(item, play = true, afterItem = null) { + async queueGrouplikeItem(topItem, play = true, afterItem = null) { const newTrackIndex = this.queueGrouplike.items.length - handleTrack: { + const recursivelyAddTracks = item => { // For groups, just queue all children. if (isGroup(item)) { for (const child of item.items) { - await this.queueGrouplikeItem(child, false) + recursivelyAddTracks(child) } - break handleTrack + return } const items = this.queueGrouplike.items @@ -147,10 +147,11 @@ class AppElement extends FocusElement { } else { items.push(item) } - - this.queueListingElement.buildItems() } + recursivelyAddTracks(topItem) + this.queueListingElement.buildItems() + // This is the first new track, if a group was queued. const newTrack = this.queueGrouplike.items[newTrackIndex] if (play && !this.playingTrack && newTrack) { |