From d5680c5f942b29d67a0e9ac10f7eded9b6f6b38c Mon Sep 17 00:00:00 2001 From: Florrie Date: Tue, 12 Jun 2018 21:49:35 -0300 Subject: Be safer about avoiding crashes w/ emptying queue while it's selected E.g. simply clearing the queue (c -- although this didn't cause a crash because the clear function immediately selects the main queue) or unqueueing all items (incoming commit). --- ui.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'ui.js') diff --git a/ui.js b/ui.js index 32cbb72..88d3eb0 100644 --- a/ui.js +++ b/ui.js @@ -79,6 +79,8 @@ class AppElement extends FocusElement { () => this.playGrouplikeItem(item, false))) this.queueListingElement.on('shuffle', () => this.shuffleQueue()) this.queueListingElement.on('clear', () => this.clearQueue()) + this.queueListingElement.on('select main listing', + () => this.form.selectInput(this.grouplikeListingElement)) this.paneRight.addChild(this.queueListingElement.pathElement) this.form.addInput(this.queueListingElement.pathElement, false) @@ -661,6 +663,14 @@ class QueueListingElement extends GrouplikeListingElement { return super.keyPressed(keyBuf) } } + + updateSelectedElement() { + if (this.inputs.length) { + super.updateSelectedElement() + } else { + this.emit('select main listing') + } + } } class PlaybackInfoElement extends DisplayElement { -- cgit 1.3.0-6-gf8a5