From 84c49e453336d6105655edd08e93bab071c0fc3b 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 bd73bdc..da6cff9 100644 --- a/ui.js +++ b/ui.js @@ -273,8 +273,6 @@ 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) @@ -294,6 +292,11 @@ 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) @@ -461,8 +464,8 @@ class AppElement extends FocusElement { 'handleAddedQueuePlayer', 'handleRemovedQueuePlayer', 'handleLogMessage', - 'handleGotPartyGrouplike', - 'handlePartyGrouplikeUpdated', + 'handleGotSharedSources', + 'handleSharedSourcesUpdated', 'handleSetLoopQueueAtEnd' ]) { this[key] = this[key].bind(this) @@ -535,8 +538,8 @@ class AppElement extends FocusElement { this.backend.on('added queue player', this.handleAddedQueuePlayer) this.backend.on('removed queue player', this.handleRemovedQueuePlayer) 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) this.backend.on('set-loop-queue-at-end', this.handleSetLoopQueueAtEnd) } @@ -545,8 +548,8 @@ class AppElement extends FocusElement { this.backend.removeListener('added queue player', this.handleAddedQueuePlayer) this.backend.removeListener('removed queue player', this.handleRemovedQueuePlayer) 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) this.backend.removeListener('set-loop-queue-at-end', this.handleSetLoopQueueAtEnd) } @@ -565,16 +568,21 @@ 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() } handleSetLoopQueueAtEnd() { @@ -979,7 +987,11 @@ class AppElement extends FocusElement { } emitMarkChanged() { + this.clearCachedMarkStatuses() this.emit('mark changed') + } + + clearCachedMarkStatuses() { this.cachedMarkStatuses = new Map() this.scheduleDrawWithoutPropertyChange() } @@ -1593,11 +1605,6 @@ 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