« get me outta code hell

playlist sources = only what's shared with party - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <towerofnix@gmail.com>2021-04-25 18:59:06 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-05-16 22:03:05 -0300
commit346deb2d7c7d7ae0eb3153152efab276db8367b4 (patch)
tree22375302a0a9afa2187248ebd5a46e38f8d39a74
parent8ec81c16931bd96ba55526fac983a5aaf14b93df (diff)
playlist sources = only what's shared with party
-rwxr-xr-xindex.js4
-rw-r--r--socket.js11
-rw-r--r--ui.js6
3 files changed, 10 insertions, 11 deletions
diff --git a/index.js b/index.js
index ec79f05..8888d48 100755
--- a/index.js
+++ b/index.js
@@ -201,9 +201,7 @@ async function main() {
   }
 
   if (socketClient) {
-    attachBackendToSocketClient(backend, socketClient, {
-      getPlaylistSources: () => appElement.playlistSources
-    })
+    attachBackendToSocketClient(backend, socketClient)
 
     let nickname = process.env.USER
     if (options['socket-name']) {
diff --git a/socket.js b/socket.js
index b9e4ccf..33269ee 100644
--- a/socket.js
+++ b/socket.js
@@ -496,9 +496,7 @@ export function makeSocketClient() {
   return client
 }
 
-export function attachBackendToSocketClient(backend, client, {
-  getPlaylistSources
-}) {
+export function attachBackendToSocketClient(backend, client) {
   // All actual logic for instances of the mtui backend interacting with each
   // other through commands lives here.
 
@@ -512,6 +510,9 @@ export function attachBackendToSocketClient(backend, client, {
 
   const partyGrouplikeMap = Object.create(null)
 
+  const getPlaylistSources = () =>
+    partyGrouplike.items.map(item => item[originalSymbol])
+
   backend.setHasAnnouncedJoin(false)
   backend.setAlwaysStartPaused(true)
   backend.setWaitWhenDonePlaying(true)
@@ -644,8 +645,6 @@ export function attachBackendToSocketClient(backend, client, {
             return
           case 'initialize-backend':
             await restoreBackend(backend, command.backend)
-            // TODO: does this need to be called here?
-            updateRestoredTracksUsingPlaylists(backend, getPlaylistSources())
             backend.on('playing', QP => {
               QP.once('received time data', () => {
                 client.sendCommand({code: 'status', status: 'sync-playback'})
@@ -902,6 +901,8 @@ export function attachBackendToSocketClient(backend, client, {
       partyGrouplike.items.push(deserialized)
       backend.partyGrouplikeUpdated(client.socketId, partyGrouplike)
 
+      updateRestoredTracksUsingPlaylists(backend, getPlaylistSources())
+
       client.sendCommand({
         code: 'share-with-party',
         item: serialized
diff --git a/ui.js b/ui.js
index a83446c..b64763b 100644
--- a/ui.js
+++ b/ui.js
@@ -184,7 +184,7 @@ export default class AppElement extends FocusElement {
     this.isPartyHost = false
     this.enableAutoDJ = false
 
-    this.playlistSources = []
+    // this.playlistSources = []
 
     this.config = Object.assign({
       canControlPlayback: true,
@@ -1645,8 +1645,8 @@ export default class AppElement extends FocusElement {
 
     grouplike = await processSmartPlaylist(grouplike)
 
-    this.playlistSources.push(grouplike)
-    updateRestoredTracksUsingPlaylists(this.backend, this.playlistSources)
+    // this.playlistSources.push(grouplike)
+    // updateRestoredTracksUsingPlaylists(this.backend, this.playlistSources)
 
     if (!this.tabber.currentElement || newTab && this.tabber.currentElement.grouplike) {
       const grouplikeListing = this.newGrouplikeListing()