From b4c07641144d27d9a4961b2e2cff682b28ca861d Mon Sep 17 00:00:00 2001 From: Florrie Date: Wed, 4 Jul 2018 23:22:37 -0300 Subject: Stub newGrouplikeListing --- index.js | 2 +- ui.js | 72 ++++++++++++++++++++++++++++++++++------------------------------ 2 files changed, 39 insertions(+), 35 deletions(-) diff --git a/index.js b/index.js index c0e2932..7ecccc7 100755 --- a/index.js +++ b/index.js @@ -67,7 +67,7 @@ async function main() { grouplike = await processSmartPlaylist(grouplike) - appElement.grouplikeListingElement.loadGrouplike(grouplike) + appElement.tabber.currentElement.loadGrouplike(grouplike) root.select(appElement) diff --git a/ui.js b/ui.js index 01e5b1a..43039e1 100644 --- a/ui.js +++ b/ui.js @@ -47,36 +47,7 @@ class AppElement extends FocusElement { this.paneLeft.addChild(this.tabber) this.form.addInput(this.tabber, false) - this.grouplikeListingElement = new GrouplikeListingElement(this.recordStore) - this.tabber.addTab(this.grouplikeListingElement) - - const handleSelectFromMain = item => { - if (isGroup(item)) { - this.grouplikeListingElement.loadGrouplike(item) - } else { - this.playGrouplikeItem(item) - } - } - - this.grouplikeListingElement.on('download', item => this.downloadGrouplikeItem(item)) - this.grouplikeListingElement.on('select (enter)', item => handleSelectFromMain(item)) - this.grouplikeListingElement.on('select (space)', item => this.handleSpacePressed( - () => handleSelectFromMain(item))) - this.grouplikeListingElement.on('queue', item => this.queueGrouplikeItem(item)) - this.grouplikeListingElement.on('queue (shuffled)', item => this.shuffleQueueGrouplikeItem(item)) - - const handleSelectFromPathElement = item => { - this.form.selectInput(this.grouplikeListingElement) - if (isGroup(item)) { - this.grouplikeListingElement.loadGrouplike(item) - } else if (item[parentSymbol]) { - this.grouplikeListingElement.loadGrouplike(item[parentSymbol]) - this.grouplikeListingElement.selectAndShow(item) - } - } - - this.form.addInput(this.grouplikeListingElement.pathElement, false) - this.grouplikeListingElement.pathElement.on('select', item => handleSelectFromPathElement(item)) + this.newGrouplikeListing() this.queueListingElement = new QueueListingElement(this.recordStore) this.queueListingElement.loadGrouplike(this.queueGrouplike) @@ -90,7 +61,7 @@ class AppElement extends FocusElement { this.queueListingElement.on('shuffle', () => this.shuffleQueue()) this.queueListingElement.on('clear', () => this.clearQueue()) this.queueListingElement.on('select main listing', - () => this.form.selectInput(this.grouplikeListingElement)) + () => this.form.selectInput(this.tabber)) this.form.addInput(this.queueListingElement.pathElement, false) this.queueListingElement.pathElement.on('select', item => handleSelectFromPathElement(item)) @@ -116,6 +87,39 @@ class AppElement extends FocusElement { this.root.select(this.form) } + newGrouplikeListing() { + const grouplikeListing = new GrouplikeListingElement(this.recordStore) + this.tabber.addTab(grouplikeListing) + + const handleSelectFromMain = item => { + if (isGroup(item)) { + grouplikeListing.loadGrouplike(item) + } else { + this.playGrouplikeItem(item) + } + } + + grouplikeListing.on('download', item => this.downloadGrouplikeItem(item)) + grouplikeListing.on('select (enter)', item => handleSelectFromMain(item)) + grouplikeListing.on('select (space)', item => this.handleSpacePressed( + () => handleSelectFromMain(item))) + grouplikeListing.on('queue', item => this.queueGrouplikeItem(item)) + grouplikeListing.on('queue (shuffled)', item => this.shuffleQueueGrouplikeItem(item)) + + const handleSelectFromPathElement = item => { + this.form.selectInput(grouplikeListing) + if (isGroup(item)) { + grouplikeListing.loadGrouplike(item) + } else if (item[parentSymbol]) { + grouplikeListing.loadGrouplike(item[parentSymbol]) + grouplikeListing.selectAndShow(item) + } + } + + // this.form.addInput(grouplikeListing.pathElement, false) + grouplikeListing.pathElement.on('select', item => handleSelectFromPathElement(item)) + } + async handlePlaylistSource(source) { this.openPlaylistDialog.close() this.alertDialog.showMessage('Opening playlist...', false) @@ -139,7 +143,7 @@ class AppElement extends FocusElement { this.root.select(this.form) grouplike = await processSmartPlaylist(grouplike) - this.grouplikeListingElement.loadGrouplike(grouplike) + this.tabber.currentElement.loadGrouplike(grouplike) } openPlaylist(arg) { @@ -220,8 +224,8 @@ class AppElement extends FocusElement { this.playPreviousTrack(this.playingTrack) } else if (telc.isShiftDown(keyBuf) || telc.isCaselessLetter(keyBuf, 'n')) { this.playNextTrack(this.playingTrack) - } else if (telc.isCharacter(keyBuf, '1') && this.grouplikeListingElement.selectable) { - this.form.curIndex = this.form.inputs.indexOf(this.grouplikeListingElement) + } else if (telc.isCharacter(keyBuf, '1') && this.tabber.selectable) { + this.form.curIndex = this.form.inputs.indexOf(this.tabber) this.form.updateSelectedElement() } else if (telc.isCharacter(keyBuf, '2') && this.queueListingElement.selectable) { this.form.curIndex = this.form.inputs.indexOf(this.queueListingElement) -- cgit 1.3.0-6-gf8a5