From d50b0391044ed0c15ea996577164300bd518c0e9 Mon Sep 17 00:00:00 2001 From: default Date: Fri, 15 Mar 2024 19:05:42 +0100 Subject: [PATCH] Set display to none for children details that are empty. --- html.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/html.c b/html.c index 667b795..0669145 100644 --- a/html.c +++ b/html.c @@ -1858,6 +1858,8 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, xs_list *p = children; char *cmd5; + int cnt = 0; + while (xs_list_iter(&p, &cmd5)) { xs *chd = NULL; @@ -1866,23 +1868,33 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, else object_get_by_md5(cmd5, &chd); - if (chd != NULL && xs_is_null(xs_dict_get(chd, "name"))) { - xs_html *che = html_entry(user, chd, read_only, level + 1, cmd5, hide_children); + if (chd != NULL) { + 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 (left > 3) - xs_html_add(ch_older, - che); - else - xs_html_add(ch_container, - che); + if (che != NULL) { + if (left > 3) + xs_html_add(ch_older, + che); + else + xs_html_add(ch_container, + che); + + cnt++; + } } + + left--; } else srv_debug(2, xs_fmt("cannot read child %s", cmd5)); - - left--; } + + /* if no children were finally added, hide the details */ + if (cnt == 0) + xs_html_add(ch_details, + xs_html_attr("style", "display: none")); } }