From 685b25af14b6500634f178af7e8698568ff65cc5 Mon Sep 17 00:00:00 2001 From: default Date: Mon, 31 Oct 2022 15:54:07 +0100 Subject: [PATCH] After reacting to a post, redirection is done to the next entry instead of top. This work more or less ok for level 0 entries, but it's very confusing for the others. --- html.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/html.c b/html.c index 8b0d3d2..d3eed6c 100644 --- a/html.c +++ b/html.c @@ -346,7 +346,7 @@ d_char *build_mentions(snac *snac, char *msg) } -d_char *html_entry_controls(snac *snac, d_char *os, char *msg) +d_char *html_entry_controls(snac *snac, d_char *os, char *msg, int num) { char *id = xs_dict_get(msg, "id"); char *actor = xs_dict_get(msg, "attributedTo"); @@ -362,6 +362,7 @@ d_char *html_entry_controls(snac *snac, d_char *os, char *msg) "
\n" "\n" "\n" + "\n" "\n", - snac->actor, id, actor, + snac->actor, id, actor, num, L("Reply"), md5 ); @@ -447,6 +448,7 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, xs_set *seen, int local, i char *actor; int sensitive = 0; char *v; + int num = xs_list_len(seen->list); /* do not show non-public messages in the public timeline */ if (local && !is_msg_public(snac, msg)) @@ -458,6 +460,12 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, xs_set *seen, int local, i xs *s = xs_str_new(NULL); + { + xs *s1 = xs_fmt("\n", num); + + s = xs_str_cat(s, s1); + } + if (strcmp(type, "Follow") == 0) { s = xs_str_cat(s, "
\n"); @@ -664,7 +672,7 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, xs_set *seen, int local, i /** controls **/ if (!local) - s = html_entry_controls(snac, s, msg); + s = html_entry_controls(snac, s, msg, num + 1); /** children **/ @@ -1112,7 +1120,12 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size, } if (status == 303) { - *body = xs_fmt("%s/admin#snac-posts", snac.actor); + char *redir = xs_dict_get(p_vars, "redir"); + + if (xs_is_null(redir)) + redir = "snac-posts"; + + *body = xs_fmt("%s/admin#%s", snac.actor, redir); *b_size = strlen(*body); }