diff options
-rw-r--r-- | client.js | 3 | ||||
-rwxr-xr-x | index.js | 2 | ||||
-rw-r--r-- | ui.js | 34 |
3 files changed, 21 insertions, 18 deletions
diff --git a/client.js b/client.js index 33cc62a..645fe42 100644 --- a/client.js +++ b/client.js @@ -70,8 +70,7 @@ const setupClient = async ({backend, writable, interfacer, appConfig}) => { ' or pass mtui your own playlist.json file!)'), source: ['crawl-local', os.homedir() + '/Music'] } - grouplike = await processSmartPlaylist(grouplike) - appElement.tabber.currentElement.loadGrouplike(grouplike) + await appElement.loadPlaylistOrSource(grouplike, true) root.select(appElement) diff --git a/index.js b/index.js index c40bbb9..4b7654d 100755 --- a/index.js +++ b/index.js @@ -125,7 +125,7 @@ async function main() { const loadPlaylists = async () => { for (const source of playlistSources) { - await appElement.handlePlaylistSource(source, true) + await appElement.loadPlaylistOrSource(source, true) } } diff --git a/ui.js b/ui.js index 04c65c0..41ab4cc 100644 --- a/ui.js +++ b/ui.js @@ -295,8 +295,8 @@ class AppElement extends FocusElement { this.openPlaylistDialog = new OpenPlaylistDialog() this.setupDialog(this.openPlaylistDialog) - this.openPlaylistDialog.on('source selected', source => this.handlePlaylistSource(source)) - this.openPlaylistDialog.on('source selected (new tab)', source => this.handlePlaylistSource(source, true)) + this.openPlaylistDialog.on('source selected', source => this.loadPlaylistOrSource(source)) + this.openPlaylistDialog.on('source selected (new tab)', source => this.loadPlaylistOrSource(source, true)) this.alertDialog = new AlertDialog() this.setupDialog(this.alertDialog) @@ -944,7 +944,7 @@ class AppElement extends FocusElement { openSpecialOrThroughSystem(item) { if (item.url.endsWith('.json')) { - return this.handlePlaylistSource(item.url, true) + return this.loadPlaylistOrSource(item.url, true) /* } else if (item.url.endsWith('.txt')) { if (this.textInfoPane.visible) { @@ -1094,7 +1094,7 @@ class AppElement extends FocusElement { }) } - async handlePlaylistSource(source, newTab = false) { + async loadPlaylistOrSource(sourceOrPlaylist, newTab = false) { if (this.openPlaylistDialog.visible) { this.openPlaylistDialog.close() } @@ -1102,18 +1102,22 @@ class AppElement extends FocusElement { this.alertDialog.showMessage('Opening playlist...', false) let grouplike - try { - grouplike = await this.openPlaylist(source) - } catch (error) { - if (error === 'unknown argument') { - this.alertDialog.showMessage('Could not figure out how to load a playlist from: ' + source) - } else if (typeof error === 'string') { - this.alertDialog.showMessage(error) - } else { - throw error - } + if (typeof sourceOrPlaylist === 'object' && isGroup(sourceOrPlaylist) || sourceOrPlaylist.source) { + grouplike = sourceOrPlaylist + } else { + try { + grouplike = await this.openPlaylist(sourceOrPlaylist) + } catch (error) { + if (error === 'unknown argument') { + this.alertDialog.showMessage('Could not figure out how to load a playlist from: ' + sourceOrPlaylist) + } else if (typeof error === 'string') { + this.alertDialog.showMessage(error) + } else { + throw error + } - return + return + } } this.alertDialog.close() |