curds: Pop empty playlists earlier during playlist.next()
Rather than waiting until the next next() call, we can detect and remove them right away. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
99de9c0f7d
commit
1b88795d17
|
@ -27,13 +27,19 @@ def lookup(name):
|
|||
def next():
|
||||
global Track
|
||||
with Lock:
|
||||
Track = Current[0].next()
|
||||
orig = Current[0]
|
||||
Track = orig.next()
|
||||
|
||||
while Track == None and len(Current) > 1:
|
||||
Current.pop(0).changed()
|
||||
Current[0].changed()
|
||||
Current.pop(0)
|
||||
Track = Current[0].next()
|
||||
|
||||
if len(Current[0]) == 0 and len(Current) > 1:
|
||||
Current.pop(0)
|
||||
if orig != Current[0]:
|
||||
orig.changed()
|
||||
Current[0].changed()
|
||||
|
||||
Root.lookup("Previous").add(Track)
|
||||
return Track
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ class TestPlaylist(unittest.TestCase):
|
|||
|
||||
track1 = playlist.next()
|
||||
self.assertEqual(playlist.Track, track1)
|
||||
self.assertEqual(playlist.Current, [ upnxt, clist ])
|
||||
self.assertEqual(playlist.Current, [ clist ])
|
||||
|
||||
self.assertEqual(len(prev), 1)
|
||||
self.assertEqual(prev[0], track1)
|
||||
|
|
Loading…
Reference in New Issue