commit 83c2888
default
·
2025-03-17 18:58:17 +0000 UTC
parent 0a8298f
If a child post is from the same author, don't indent it.
1 files changed,
+36,
-2
M
html.c
M
html.c
+36,
-2
1@@ -2585,6 +2585,12 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
2 xs_html_add(entry,
3 ch_details);
4
5+ xs_html *fch_container = xs_html_tag("div",
6+ xs_html_attr("class", "snac-thread-cont"));
7+
8+ xs_html_add(ch_details,
9+ fch_container);
10+
11 xs_html *ch_container = xs_html_tag("div",
12 xs_html_attr("class", level < 4 ? "snac-children" : "snac-children-too-deep"));
13
14@@ -2599,12 +2605,40 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
15 xs_html_text(L("Older...")))));
16 }
17
18- xs_list *p = children;
19+ int ctxt = 0;
20 const char *cmd5;
21 int cnt = 0;
22 int o_cnt = 0;
23
24- while (xs_list_iter(&p, &cmd5)) {
25+ /* get the first child */
26+ xs_list_next(children, &cmd5, &ctxt);
27+ xs *f_chd = NULL;
28+
29+ if (user)
30+ timeline_get_by_md5(user, cmd5, &f_chd);
31+ else
32+ object_get_by_md5(cmd5, &f_chd);
33+
34+ if (f_chd != NULL && xs_is_null(xs_dict_get(f_chd, "name"))) {
35+ const char *p_author = get_atto(msg);
36+ const char *author = get_atto(f_chd);
37+
38+ /* is the first child from the same author? */
39+ if (xs_is_string(p_author) && xs_is_string(author) && strcmp(p_author, author) == 0) {
40+ /* then, don't add it to the children container,
41+ so that it appears unindented just before the parent
42+ like a fucking Twitter-like thread */
43+ xs_html_add(fch_container,
44+ html_entry(user, f_chd, read_only, level + 1, cmd5, hide_children));
45+
46+ cnt++;
47+ left--;
48+ }
49+ else
50+ ctxt = 0; /* restart from the beginning */
51+ }
52+
53+ while (xs_list_next(children, &cmd5, &ctxt)) {
54 xs *chd = NULL;
55
56 if (user)