Don't generate empty children popups.

This commit is contained in:
default 2023-01-03 10:11:20 +01:00
parent abd56da2ba
commit 845df51686

27
html.c
View file

@ -764,17 +764,19 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, int local, int level, cons
if (left) { if (left) {
char *p, *cmd5; char *p, *cmd5;
int older_open = 0; int older_open = 0;
xs *ss = xs_str_new(NULL);
int n_children = 0;
s = xs_str_cat(s, "<details open><summary>...</summary><p>\n"); ss = xs_str_cat(ss, "<details open><summary>...</summary><p>\n");
if (level < 4) if (level < 4)
s = xs_str_cat(s, "<div class=\"snac-children\">\n"); ss = xs_str_cat(ss, "<div class=\"snac-children\">\n");
else else
s = xs_str_cat(s, "<div>\n"); ss = xs_str_cat(ss, "<div>\n");
if (left > 3) { if (left > 3) {
xs *s1 = xs_fmt("<details><summary>%s</summary>\n", L("Older...")); xs *s1 = xs_fmt("<details><summary>%s</summary>\n", L("Older..."));
s = xs_str_cat(s, s1); ss = xs_str_cat(ss, s1);
older_open = 1; older_open = 1;
} }
@ -784,12 +786,14 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, int local, int level, cons
object_get_by_md5(cmd5, &chd, NULL); object_get_by_md5(cmd5, &chd, NULL);
if (older_open && left <= 3) { if (older_open && left <= 3) {
s = xs_str_cat(s, "</details>\n"); ss = xs_str_cat(ss, "</details>\n");
older_open = 0; older_open = 0;
} }
if (chd != NULL) if (chd != NULL) {
s = html_entry(snac, s, chd, local, level + 1, cmd5); ss = html_entry(snac, ss, chd, local, level + 1, cmd5);
n_children++;
}
else else
snac_debug(snac, 2, xs_fmt("cannot read from timeline child %s", cmd5)); snac_debug(snac, 2, xs_fmt("cannot read from timeline child %s", cmd5));
@ -797,10 +801,13 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, int local, int level, cons
} }
if (older_open) if (older_open)
s = xs_str_cat(s, "</details>\n"); ss = xs_str_cat(ss, "</details>\n");
s = xs_str_cat(s, "</div>\n"); ss = xs_str_cat(ss, "</div>\n");
s = xs_str_cat(s, "</details>\n"); ss = xs_str_cat(ss, "</details>\n");
if (n_children)
s = xs_str_cat(s, ss);
} }
s = xs_str_cat(s, "</div>\n</div>\n"); s = xs_str_cat(s, "</div>\n</div>\n");