core/playlists/system: Reset queued tracks when empty
Users might not remember any sorting or random settings from the last time they queued tracks, so saving these values could result in selecting tracks in an unexpected order. Fix this by resetting the queued tracks options whenever the playlist is emptied. Fixes #108: Unset random and sorting when finishing queued tracks Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
bb40ef479f
commit
cc5f65bf82
|
@ -161,11 +161,26 @@ static bool sys_pl_queued_load()
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool sys_pl_queued_delete(struct playlist *playlist)
|
||||
{
|
||||
playlist_generic_set_random(playlist, false);
|
||||
playlist_clear_sort(playlist);
|
||||
return sys_pl_delete_clear(playlist);
|
||||
}
|
||||
|
||||
static bool sys_pl_queued_remove(struct playlist *playlist, struct track *track)
|
||||
{
|
||||
bool ret = playlist_generic_remove(playlist, track);
|
||||
if (playlist_size(playlist) == 0)
|
||||
sys_pl_queued_delete(playlist);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct playlist_ops queued_ops = {
|
||||
.pl_add = playlist_generic_add,
|
||||
.pl_can_select = playlist_generic_can_select,
|
||||
.pl_delete = sys_pl_delete_clear,
|
||||
.pl_remove = playlist_generic_remove,
|
||||
.pl_delete = sys_pl_queued_delete,
|
||||
.pl_remove = sys_pl_queued_remove,
|
||||
.pl_set_random = playlist_generic_set_random,
|
||||
.pl_sort = playlist_generic_sort,
|
||||
};
|
||||
|
@ -370,7 +385,7 @@ static void pl_system_selected(struct track *track)
|
|||
{
|
||||
unsigned int i;
|
||||
|
||||
playlist_generic_remove(pl_system_get(SYS_PL_QUEUED), track);
|
||||
sys_pl_queued_remove(pl_system_get(SYS_PL_QUEUED), track);
|
||||
for (i = 0; i < SYS_PL_NUM_PLAYLISTS; i++)
|
||||
playlist_generic_update(pl_system_get(i), track);
|
||||
}
|
||||
|
|
|
@ -212,6 +212,9 @@ static void test_remove()
|
|||
struct playlist *playlist;
|
||||
unsigned int i;
|
||||
|
||||
playlist_set_random(__test_pl_queued(), true);
|
||||
g_assert_true(playlist_sort(__test_pl_queued(), COMPARE_TRACK));
|
||||
|
||||
g_assert_true( playlist_remove(__test_pl_favorites(), track_get(0)));
|
||||
g_assert_false(playlist_remove(__test_pl_favorites(), track_get(0)));
|
||||
g_assert_true( playlist_remove(__test_pl_queued(), track_get(0)));
|
||||
|
@ -261,9 +264,11 @@ static void test_remove()
|
|||
playlist = playlist_get(PL_SYSTEM, i);
|
||||
|
||||
switch (i) {
|
||||
case SYS_PL_QUEUED:
|
||||
g_assert_false(playlist->pl_random);
|
||||
g_assert_cmpuint(g_slist_length(playlist->pl_sort), ==, 0);
|
||||
case SYS_PL_FAVORITES:
|
||||
case SYS_PL_HIDDEN:
|
||||
case SYS_PL_QUEUED:
|
||||
case SYS_PL_HISTORY:
|
||||
g_assert_false(playlist_select(playlist));
|
||||
g_assert(playlist_current() != playlist);
|
||||
|
@ -280,11 +285,14 @@ static void test_delete()
|
|||
{
|
||||
unsigned int i;
|
||||
|
||||
playlist_add(__test_pl_favorites(), track_get(0));
|
||||
playlist_add(__test_pl_hidden(), track_get(1));
|
||||
playlist_add(__test_pl_hidden(), track_get(2));
|
||||
playlist_add(__test_pl_queued(), track_get(0));
|
||||
playlist_add(__test_pl_history(), track_get(0));
|
||||
g_assert_true(playlist_add(__test_pl_favorites(), track_get(0)));
|
||||
g_assert_true(playlist_add(__test_pl_hidden(), track_get(1)));
|
||||
g_assert_true(playlist_add(__test_pl_hidden(), track_get(2)));
|
||||
g_assert_true(playlist_add(__test_pl_queued(), track_get(0)));
|
||||
g_assert_true(playlist_add(__test_pl_history(), track_get(0)));
|
||||
|
||||
playlist_set_random(__test_pl_queued(), true);
|
||||
g_assert_true(playlist_sort(__test_pl_queued(), COMPARE_TRACK));
|
||||
|
||||
for (i = 0; i < SYS_PL_NUM_PLAYLISTS; i++)
|
||||
g_assert_false(playlist_delete(playlist_get(PL_SYSTEM, i)));
|
||||
|
@ -297,6 +305,9 @@ static void test_delete()
|
|||
g_assert_cmpuint(playlist_size(__test_pl_unplayed()), ==, 1);
|
||||
g_assert_cmpuint(playlist_size(__test_pl_most_played()), ==, 1);
|
||||
g_assert_cmpuint(playlist_size(__test_pl_least_played()), ==, 1);
|
||||
|
||||
g_assert_false(__test_pl_queued()->pl_random);
|
||||
g_assert_cmpuint(g_slist_length(__test_pl_queued()->pl_sort), ==, 0);
|
||||
}
|
||||
|
||||
static void test_next()
|
||||
|
|
Loading…
Reference in New Issue