« get me outta code hell

mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/socket.js
diff options
context:
space:
mode:
Diffstat (limited to 'socket.js')
-rw-r--r--socket.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/socket.js b/socket.js
index 2890efb..7760334 100644
--- a/socket.js
+++ b/socket.js
@@ -503,9 +503,7 @@ function makeSocketClient() {
   return client
 }
 
-function attachBackendToSocketClient(backend, client, {
-  getPlaylistSources
-}) {
+function attachBackendToSocketClient(backend, client) {
   // All actual logic for instances of the mtui backend interacting with each
   // other through commands lives here.
 
@@ -519,6 +517,9 @@ 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)
@@ -651,8 +652,6 @@ 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'})
@@ -909,6 +908,8 @@ function attachBackendToSocketClient(backend, client, {
       partyGrouplike.items.push(deserialized)
       backend.partyGrouplikeUpdated(client.socketId, partyGrouplike)
 
+      updateRestoredTracksUsingPlaylists(backend, getPlaylistSources())
+
       client.sendCommand({
         code: 'share-with-party',
         item: serialized