From ebbdaa3473b4885468eb27922e24511c93b962ca Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 26 Apr 2021 13:15:09 -0300 Subject: synchronize shared sources on join + other stuff --- ui.js | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'ui.js') diff --git a/ui.js b/ui.js index 7e36858..371da80 100644 --- a/ui.js +++ b/ui.js @@ -264,8 +264,6 @@ export default class AppElement extends FocusElement { this.metadataStatusLabel.visible = false this.tabberPane.addChild(this.metadataStatusLabel) - this.newGrouplikeListing() - this.queueListingElement = new QueueListingElement(this) this.setupCommonGrouplikeListingEvents(this.queueListingElement) this.queuePane.addChild(this.queueListingElement) @@ -285,6 +283,11 @@ export default class AppElement extends FocusElement { this.queueListingElement.on('select main listing', () => this.selected()) + if (this.config.showPartyControls) { + const sharedSourcesListing = this.newGrouplikeListing() + sharedSourcesListing.loadGrouplike(this.backend.sharedSourcesGrouplike) + } + this.playbackPane = new Pane() this.addChild(this.playbackPane) @@ -481,8 +484,8 @@ export default class AppElement extends FocusElement { 'handleRemovedQueuePlayer', 'handleSetLoopQueueAtEnd', 'handleLogMessage', - 'handleGotPartyGrouplike', - 'handlePartyGrouplikeUpdated' + 'handleGotSharedSources', + 'handleSharedSourcesUpdated' ]) { this[key] = this[key].bind(this) } @@ -555,8 +558,8 @@ export default class AppElement extends FocusElement { this.backend.on('removed queue player', this.handleRemovedQueuePlayer) this.backend.on('set-loop-queue-at-end', this.handleSetLoopQueueAtEnd) this.backend.on('log message', this.handleLogMessage) - this.backend.on('got party grouplike', this.handleGotPartyGrouplike) - this.backend.on('party grouplike updated', this.handlePartyGrouplikeUpdated) + this.backend.on('got shared sources', this.handleGotSharedSources) + this.backend.on('shared sources updated', this.handleSharedSourcesUpdated) } removeBackendListeners() { @@ -565,8 +568,8 @@ export default class AppElement extends FocusElement { this.backend.removeListener('removed queue player', this.handleRemovedQueuePlayer) this.backend.removeListener('set-loop-queue-at-end', this.handleSetLoopQueueAtEnd) this.backend.removeListener('log message', this.handleLogMessage) - this.backend.removeListener('got party grouplike', this.handleGotPartyGrouplike) - this.backend.removeListener('party grouplike updated', this.handlePartyGrouplikeUpdated) + this.backend.removeListener('got shared sources', this.handleGotSharedSources) + this.backend.removeListener('shared sources updated', this.handleSharedSourcesUpdated) } handleAddedQueuePlayer(queuePlayer) { @@ -588,16 +591,21 @@ export default class AppElement extends FocusElement { this.log.newLogMessage(messageInfo) } - handleGotPartyGrouplike(socketId, partyGrouplike) { - this.newPartyTab(socketId, partyGrouplike) + handleGotSharedSources(socketId, sharedSources) { + for (const grouplikeListing of this.tabber.tabberElements) { + if (grouplikeListing.grouplike === this.backend.sharedSourcesGrouplike) { + grouplikeListing.loadGrouplike(this.backend.sharedSourcesGrouplike, false) + } + } } - handlePartyGrouplikeUpdated(socketId, partyGrouplike) { + handleSharedSourcesUpdated(socketId, partyGrouplike) { for (const grouplikeListing of this.tabber.tabberElements) { if (grouplikeListing.grouplike === partyGrouplike) { grouplikeListing.loadGrouplike(partyGrouplike, false) } } + this.clearCachedMarkStatuses() } async handlePlayingDetails(track, oldTrack, startTime, queuePlayer) { @@ -1093,7 +1101,11 @@ export default class AppElement extends FocusElement { } emitMarkChanged() { + this.clearCachedMarkStatuses() this.emit('mark changed') + } + + clearCachedMarkStatuses() { this.cachedMarkStatuses = new Map() this.scheduleDrawWithoutPropertyChange() } @@ -1961,11 +1973,6 @@ export default class AppElement extends FocusElement { }) } - newPartyTab(socketId, partyGrouplike) { - const listing = this.newGrouplikeListing() - listing.loadGrouplike(partyGrouplike) - } - cloneCurrentTab() { const grouplike = this.tabber.currentElement.grouplike const listing = this.newGrouplikeListing() -- cgit 1.3.0-6-gf8a5