From 74177b054687487fb3f55fc5fdf8dfae77cd9f98 Mon Sep 17 00:00:00 2001 From: Etoh Date: Fri, 24 Feb 2023 14:22:04 +0000 Subject: [PATCH] Restore server-side playlist on reconnect (v2) --- syncplay/client.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/syncplay/client.py b/syncplay/client.py index 262686d..6f99a39 100755 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -1932,10 +1932,16 @@ class SyncplayPlaylist(): def playlistNeedsRestoring(self, files, username): return self._client.sharedPlaylistIsEnabled() and self._playlist != None and files == [] and username == None and not self._playlistBufferIsFromOldRoom(self._client.userlist.currentUser.room) + def playlistNeedsRestoring(self, files, username): + return self._client.sharedPlaylistIsEnabled() and len(self._playlist) > 0 and not files and username == None and (self._previousPlaylistRoom == None or self._previousPlaylistRoom == self._client.userlist.currentUser.room) + def changePlaylist(self, files, username=None, resetIndex=False): if self.playlistNeedsRestoring(files, username): + self._ui.showDebugMessage("Restoring playlist on reconnect...") files = self._playlist.copy() - self._playlist = [] + self._client._protocol.setPlaylist(files) + self._client._protocol.setPlaylistIndex(self._playlistIndex) + return self.queuedIndexFilename = None if self._playlist == files: if self._playlistIndex != 0 and resetIndex: