From c283c559c777eab7a533a38a646607a91e98bd6f Mon Sep 17 00:00:00 2001 From: Florrie Date: Fri, 1 Jun 2018 17:59:27 -0300 Subject: Only call buildItems once when a group is queued --- todo.txt | 3 --- 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) { -- cgit 1.3.0-6-gf8a5