curds: Clear the current list when selecting the Collection playlist

The collection playlist always has loop=True, so we'll never pop it from
the stack under normal conditions. Let's clear the list when selecting
this playlist so we don't keep a list of unreachable playlists.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2019-04-14 17:32:41 -04:00
parent b1521c3d35
commit 6c0d269b2d
2 changed files with 9 additions and 1 deletions

View File

@ -149,6 +149,8 @@ class PlaylistManager(PlaylistManagerBase):
self.track = None
def select(self, plist):
if plist in self.current:
if plist == self.lookup("Collection"):
self.current = [ ]
elif plist in self.current:
self.current.remove(plist)
self.current.insert(0, plist)

View File

@ -256,5 +256,11 @@ class TestPlaylistManager(unittest.TestCase):
self.assertEqual(self.playman.next(), glist[0])
self.assertEqual(self.playman.current, [ glist, clist ])
self.playman.select(plist)
self.assertEqual(self.playman.current, [ plist, glist, clist ])
self.playman.select(clist)
self.assertEqual(self.playman.current, [ clist ])
self.playman.select(plist)
self.playman.reset()
self.assertEqual(self.playman.current, [ clist ])