From 773be130ed4557c95fef2d54799a170ffea9e0de Mon Sep 17 00:00:00 2001 From: default Date: Wed, 2 Nov 2022 10:49:16 +0100 Subject: More work in the people page. --- html.c | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'html.c') diff --git a/html.c b/html.c index 80b7f43..b20b0d0 100644 --- a/html.c +++ b/html.c @@ -820,28 +820,19 @@ d_char *html_timeline(snac *snac, char *list, int local) } -d_char *html_people(snac *snac) +d_char *html_people_list(snac *snac, d_char *os, d_char *list, const char *header) { - d_char *s = xs_str_new(NULL); - xs *wers = NULL; - xs *wing = NULL; + xs *s = xs_str_new(NULL); + xs *h = xs_fmt("

%s

\n", header); char *p, *v; - s = html_user_header(snac, s, 0); - - s = xs_str_cat(s, "

"); - s = xs_str_cat(s, L("People you follow")); - s = xs_str_cat(s, "

\n"); + s = xs_str_cat(s, h); - s = xs_str_cat(s, "

"); - s = xs_str_cat(s, L("People that follows you")); - s = xs_str_cat(s, "

\n"); - - p = wers = follower_list(snac); + p = list; while (xs_list_iter(&p, &v)) { char *actor_id = xs_dict_get(v, "actor"); xs *md5 = xs_md5_hex(actor_id, strlen(actor_id)); - xs *actor; + xs *actor = NULL; if (valid_status(actor_get(snac, actor_id, &actor))) { s = xs_str_cat(s, "
\n"); @@ -888,7 +879,10 @@ d_char *html_people(snac *snac) ); s = xs_str_cat(s, s1); - s = html_button(s, "unfollow", L("Unfollow")); + if (following_check(snac, actor_id)) + s = html_button(s, "unfollow", L("Unfollow")); + else + s = html_button(s, "follow", L("Follow")); if (is_muted(snac, actor_id)) s = html_button(s, "unmute", L("Unmute")); @@ -922,6 +916,22 @@ d_char *html_people(snac *snac) } } + return xs_str_cat(os, s); +} + + +d_char *html_people(snac *snac) +{ + d_char *s = xs_str_new(NULL); + xs *wing = following_list(snac); + xs *wers = follower_list(snac); + + s = html_user_header(snac, s, 0); + + s = html_people_list(snac, s, wing, L("People you follow")); + + s = html_people_list(snac, s, wers, L("People that follows you")); + s = html_user_footer(snac, s); s = xs_str_cat(s, "\n\n"); -- cgit v1.2.3