From 2d41fd5ce9e2c821ea4da8a6650f445dbf48d641 Mon Sep 17 00:00:00 2001 From: Florrie Date: Tue, 26 Jun 2018 22:11:35 -0300 Subject: Hide/fix weird bug with empty downloaderArgs --- ui.js | 60 ++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 26 deletions(-) (limited to 'ui.js') diff --git a/ui.js b/ui.js index 371958d..9a5b727 100644 --- a/ui.js +++ b/ui.js @@ -312,38 +312,46 @@ class AppElement extends FocusElement { // TODO: Check if it's an item or a group - // If, by the time the track is downloaded, we're playing something - // different from when the download started, assume that we just want to - // keep listening to whatever new thing we started. + playTrack: { + // No downloader argument? That's no good - stop here. + // TODO: An error icon on this item, or something??? + if (!item.downloaderArg) { + break playTrack + } - const oldTrack = this.playingTrack + // If, by the time the track is downloaded, we're playing something + // different from when the download started, assume that we just want to + // keep listening to whatever new thing we started. - const downloadFile = await this.downloadGrouplikeItem(item) + const oldTrack = this.playingTrack - if (this.playingTrack !== oldTrack) { - return - } + const downloadFile = await this.downloadGrouplikeItem(item) - await this.player.kill() - this.recordStore.getRecord(item).playing = true - this.playingTrack = item - this.playbackInfoElement.updateTrack(item) - if (!this.queueListingElement.isSelected) { - this.queueListingElement.selectAndShow(item) - } + if (this.playingTrack !== oldTrack) { + return + } - await Promise.all([ - writeFile(this.rootDirectory + '/current-track.txt', - getItemPathString(item)), - writeFile(this.rootDirectory + '/current-track.json', - JSON.stringify(item, null, 2)) - ]) + await this.player.kill() + 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 { - if (playingThisTrack || this.playingTrack !== item) { - this.recordStore.getRecord(item).playing = false + await Promise.all([ + writeFile(this.rootDirectory + '/current-track.txt', + getItemPathString(item)), + writeFile(this.rootDirectory + '/current-track.json', + JSON.stringify(item, null, 2)) + ]) + + try { + await this.player.playFile(downloadFile) + } finally { + if (playingThisTrack || this.playingTrack !== item) { + this.recordStore.getRecord(item).playing = false + } } } -- cgit 1.3.0-6-gf8a5