commit d50b039
default
·
2024-03-15 18:05:42 +0000 UTC
parent 73a5fc6
Set display to none for children details that are empty.
1 files changed,
+23,
-11
M
html.c
M
html.c
+23,
-11
1@@ -1858,6 +1858,8 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
2
3 xs_list *p = children;
4 char *cmd5;
5+ int cnt = 0;
6+
7 while (xs_list_iter(&p, &cmd5)) {
8 xs *chd = NULL;
9
10@@ -1866,23 +1868,33 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
11 else
12 object_get_by_md5(cmd5, &chd);
13
14- if (chd != NULL && xs_is_null(xs_dict_get(chd, "name"))) {
15- xs_html *che = html_entry(user, chd, read_only, level + 1, cmd5, hide_children);
16+ if (chd != NULL) {
17+ if (xs_is_null(xs_dict_get(chd, "name"))) {
18+ xs_html *che = html_entry(user, chd, read_only,
19+ level + 1, cmd5, hide_children);
20+
21+ if (che != NULL) {
22+ if (left > 3)
23+ xs_html_add(ch_older,
24+ che);
25+ else
26+ xs_html_add(ch_container,
27+ che);
28
29- if (che != NULL) {
30- if (left > 3)
31- xs_html_add(ch_older,
32- che);
33- else
34- xs_html_add(ch_container,
35- che);
36+ cnt++;
37+ }
38 }
39+
40+ left--;
41 }
42 else
43 srv_debug(2, xs_fmt("cannot read child %s", cmd5));
44-
45- left--;
46 }
47+
48+ /* if no children were finally added, hide the details */
49+ if (cnt == 0)
50+ xs_html_add(ch_details,
51+ xs_html_attr("style", "display: none"));
52 }
53 }
54