From 04101b38a351b559ddfb9f21418c382a9098eda2 Mon Sep 17 00:00:00 2001 From: Florrie Date: Sat, 2 Jun 2018 13:01:45 -0300 Subject: Keep playing track in visible in queue --- ui.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'ui.js') diff --git a/ui.js b/ui.js index 57b2d9f..5ff4cba 100644 --- a/ui.js +++ b/ui.js @@ -231,6 +231,9 @@ class AppElement extends FocusElement { this.recordStore.getRecord(item).playing = true this.playingTrack = item this.playbackInfoElement.updateTrack(item) + if (!this.queueListingElement.isSelected) { + this.queueListingElement.selectAndShow(item) + } try { await this.player.playFile(downloadFile) } finally { @@ -319,8 +322,7 @@ class GrouplikeListingElement extends ListScrollForm { throw new Error('Attempted to call buildItems before a grouplike was loaded') } - const wasSelected = (this.root.selected && - this.root.selected.directAncestors.includes(this)) + const wasSelected = this.isSelected while (this.inputs.length) { this.removeInput(this.inputs[0]) @@ -365,9 +367,25 @@ class GrouplikeListingElement extends ListScrollForm { this.fixLayout() } + selectAndShow(item) { + const index = this.inputs.findIndex(inp => inp.item === item) + if (index >= 0) { + this.curIndex = index + if (this.isSelected) { + this.updateSelectedElement() + } + this.scrollSelectedElementIntoView() + } + } + get firstItemIndex() { return Math.min(this.inputs.length, 1) } + + get isSelected() { + return this.root.selected && this.root.selected.directAncestors.includes(this) + } + } class GrouplikeItemElement extends Button { -- cgit 1.3.0-6-gf8a5