Set display to none for children details that are empty.

This commit is contained in:
default 2024-03-15 19:05:42 +01:00
parent 73a5fc6f5b
commit d50b039104

20
html.c
View file

@ -1858,6 +1858,8 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
xs_list *p = children; xs_list *p = children;
char *cmd5; char *cmd5;
int cnt = 0;
while (xs_list_iter(&p, &cmd5)) { while (xs_list_iter(&p, &cmd5)) {
xs *chd = NULL; xs *chd = NULL;
@ -1866,8 +1868,10 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
else else
object_get_by_md5(cmd5, &chd); object_get_by_md5(cmd5, &chd);
if (chd != NULL && xs_is_null(xs_dict_get(chd, "name"))) { if (chd != NULL) {
xs_html *che = html_entry(user, chd, read_only, level + 1, cmd5, hide_children); if (xs_is_null(xs_dict_get(chd, "name"))) {
xs_html *che = html_entry(user, chd, read_only,
level + 1, cmd5, hide_children);
if (che != NULL) { if (che != NULL) {
if (left > 3) if (left > 3)
@ -1876,13 +1880,21 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
else else
xs_html_add(ch_container, xs_html_add(ch_container,
che); che);
cnt++;
} }
} }
else
srv_debug(2, xs_fmt("cannot read child %s", cmd5));
left--; left--;
} }
else
srv_debug(2, xs_fmt("cannot read child %s", cmd5));
}
/* if no children were finally added, hide the details */
if (cnt == 0)
xs_html_add(ch_details,
xs_html_attr("style", "display: none"));
} }
} }