Only change path when we get its contents
This commit is contained in:
parent
653ff1373f
commit
57b4a9688d
23
nncmpp.c
23
nncmpp.c
|
@ -1971,9 +1971,16 @@ static void
|
||||||
library_tab_on_data (const struct mpd_response *response,
|
library_tab_on_data (const struct mpd_response *response,
|
||||||
const struct strv *data, void *user_data)
|
const struct strv *data, void *user_data)
|
||||||
{
|
{
|
||||||
(void) user_data;
|
char *data_path = user_data;
|
||||||
if (!response->success)
|
if (!response->success)
|
||||||
|
{
|
||||||
|
free (data_path);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
str_reset (&g_library_tab.path);
|
||||||
|
str_append (&g_library_tab.path, data_path);
|
||||||
|
free (data_path);
|
||||||
|
|
||||||
strv_reset (&g_library_tab.items);
|
strv_reset (&g_library_tab.items);
|
||||||
|
|
||||||
|
@ -2017,17 +2024,13 @@ library_tab_on_data (const struct mpd_response *response,
|
||||||
static void
|
static void
|
||||||
library_tab_reload (const char *new_path)
|
library_tab_reload (const char *new_path)
|
||||||
{
|
{
|
||||||
// TODO: actually we should update the path _after_ we receive data
|
char *path = new_path
|
||||||
struct str *path = &g_library_tab.path;
|
? xstrdup (new_path)
|
||||||
if (new_path)
|
: xstrdup (g_library_tab.path.str);
|
||||||
{
|
|
||||||
str_reset (path);
|
|
||||||
str_append (path, new_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct mpd_client *c = &g.client;
|
struct mpd_client *c = &g.client;
|
||||||
mpd_client_send_command (c, "lsinfo", path->len ? path->str : "/", NULL);
|
mpd_client_send_command (c, "lsinfo", *path ? path : "/", NULL);
|
||||||
mpd_client_add_task (c, library_tab_on_data, NULL);
|
mpd_client_add_task (c, library_tab_on_data, path);
|
||||||
mpd_client_idle (c, 0);
|
mpd_client_idle (c, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue