Refactor updateUndoPlaylistBuffer
This commit is contained in:
parent
85812e29f3
commit
037e5aa21e
@ -531,11 +531,7 @@ class SyncplayClient(object):
|
|||||||
except:
|
except:
|
||||||
newIndex = 0
|
newIndex = 0
|
||||||
|
|
||||||
if self._previousPlaylistRoom <> self.userlist.currentUser.room:
|
self.updateUndoPlaylistBuffer(currentPlaylist=self._playlist, newPlaylist=files)
|
||||||
self._previousPlaylist = None
|
|
||||||
self._previousPlaylistRoom = self.userlist.currentUser.room
|
|
||||||
elif self._previousPlaylist <> self._playlist and self._playlist <> files:
|
|
||||||
self._previousPlaylist = self._playlist
|
|
||||||
self._playlist = files
|
self._playlist = files
|
||||||
|
|
||||||
if username is None and self._protocol and self._protocol.logged:
|
if username is None and self._protocol and self._protocol.logged:
|
||||||
@ -547,6 +543,22 @@ class SyncplayClient(object):
|
|||||||
self.changeToPlaylistIndex(newIndex, username)
|
self.changeToPlaylistIndex(newIndex, username)
|
||||||
self.ui.showMessage(u"{} updated the playlist".format(username))
|
self.ui.showMessage(u"{} updated the playlist".format(username))
|
||||||
|
|
||||||
|
def updateUndoPlaylistBuffer(self, currentPlaylist, newPlaylist):
|
||||||
|
if self.playlistBufferIsFromOldRoom():
|
||||||
|
self.movePlaylistBufferToNewRoom()
|
||||||
|
elif self.playlistBufferNeedsUpdating(currentPlaylist, newPlaylist):
|
||||||
|
self._previousPlaylist = currentPlaylist
|
||||||
|
|
||||||
|
def playlistBufferIsFromOldRoom(self):
|
||||||
|
return self._previousPlaylistRoom <> self.userlist.currentUser.room
|
||||||
|
|
||||||
|
def movePlaylistBufferToNewRoom(self):
|
||||||
|
self._previousPlaylist = None
|
||||||
|
self._previousPlaylistRoom = self.userlist.currentUser.room
|
||||||
|
|
||||||
|
def playlistBufferNeedsUpdating(self, currentPlaylist, newPlaylist):
|
||||||
|
return self._previousPlaylist <> currentPlaylist and currentPlaylist <> newPlaylist
|
||||||
|
|
||||||
@needsSharedPlaylistsEnabled
|
@needsSharedPlaylistsEnabled
|
||||||
def undoPlaylistChange(self):
|
def undoPlaylistChange(self):
|
||||||
if self._previousPlaylist is not None and self._playlist <> self._previousPlaylist:
|
if self._previousPlaylist is not None and self._playlist <> self._previousPlaylist:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user