Playlist restoration should not undo clearing actions (#609)

This commit is contained in:
Etoh 2023-06-02 19:15:36 +01:00
parent e4314b40f5
commit c46529bb8a
2 changed files with 4 additions and 8 deletions

View File

@ -1,5 +1,5 @@
version = '1.7.0' version = '1.7.0'
revision = '' revision = ''
milestone = 'Yoitsu' milestone = 'Yoitsu'
release_number = '106' release_number = '107'
projectURL = 'https://syncplay.pl/' projectURL = 'https://syncplay.pl/'

View File

@ -136,6 +136,7 @@ class SyncplayClient(object):
self._warnings = self._WarningManager(self._player, self.userlist, self.ui, self) self._warnings = self._WarningManager(self._player, self.userlist, self.ui, self)
self.fileSwitch = FileSwitchManager(self) self.fileSwitch = FileSwitchManager(self)
self.playlist = SyncplayPlaylist(self) self.playlist = SyncplayPlaylist(self)
self.playlistMayNeedRestoring = False
self._serverSupportsTLS = True self._serverSupportsTLS = True
@ -858,6 +859,7 @@ class SyncplayClient(object):
def retry(retries): def retry(retries):
self._lastGlobalUpdate = None self._lastGlobalUpdate = None
self.ui.setSSLMode(False) self.ui.setSSLMode(False)
self.playlistMayNeedRestoring = True
if retries == 0: if retries == 0:
self.onDisconnect() self.onDisconnect()
if retries > constants.RECONNECT_RETRIES: if retries > constants.RECONNECT_RETRIES:
@ -1954,13 +1956,6 @@ class SyncplayPlaylist():
playlistFile.write(playlistToSave) playlistFile.write(playlistToSave)
self._ui.showMessage("Playlist saved as {}".format(path)) # TODO: Move to messages_en self._ui.showMessage("Playlist saved as {}".format(path)) # TODO: Move to messages_en
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): def changePlaylist(self, files, username=None, resetIndex=False):
if self.playlistNeedsRestoring(files, username): if self.playlistNeedsRestoring(files, username):
self._ui.showDebugMessage("Restoring playlist on reconnect...") self._ui.showDebugMessage("Restoring playlist on reconnect...")
@ -1969,6 +1964,7 @@ class SyncplayPlaylist():
self._client._protocol.setPlaylistIndex(self._playlistIndex) self._client._protocol.setPlaylistIndex(self._playlistIndex)
return return
self.queuedIndexFilename = None self.queuedIndexFilename = None
self._client.playlistMayNeedRestoring = False
if self._playlist == files: if self._playlist == files:
if self._playlistIndex != 0 and resetIndex: if self._playlistIndex != 0 and resetIndex:
self.changeToPlaylistIndex(0) self.changeToPlaylistIndex(0)