commit ee84140

grunfink  ·  2025-05-18 06:23:48 +0000 UTC
parent 8ae0089
Added a pending follow request count next to the "people" link.
3 files changed,  +23, -0
M data.c
M html.c
M snac.h
M data.c
+10, -0
 1@@ -1335,6 +1335,16 @@ xs_list *pending_list(snac *user)
 2 }
 3 
 4 
 5+int pending_count(snac *user)
 6+/* returns the number of pending follow confirmations */
 7+{
 8+    xs *spec = xs_fmt("%s/pending/""*.json", user->basedir);
 9+    xs *l = xs_glob(spec, 0, 0);
10+
11+    return xs_list_len(l);
12+}
13+
14+
15 /** timeline **/
16 
17 double timeline_mtime(snac *snac)
M html.c
+12, -0
 1@@ -923,7 +923,9 @@ static xs_html *html_user_body(snac *user, int read_only)
 2     }
 3     else {
 4         int n_len = notify_new_num(user);
 5+        int p_len = pending_count(user);
 6         xs_html *notify_count = NULL;
 7+        xs_html *pending_follow_count = NULL;
 8 
 9         /* show the number of new notifications, if there are any */
10         if (n_len) {
11@@ -935,6 +937,15 @@ static xs_html *html_user_body(snac *user, int read_only)
12         else
13             notify_count = xs_html_text("");
14 
15+        if (p_len) {
16+            xs *s = xs_fmt(" %d ", p_len);
17+            pending_follow_count = xs_html_tag("sup",
18+                xs_html_attr("style", "background-color: red; color: white;"),
19+                xs_html_text(s));
20+        }
21+        else
22+            pending_follow_count = xs_html_text("");
23+
24         xs *admin_url = xs_fmt("%s/admin", user->actor);
25         xs *notify_url = xs_fmt("%s/notifications", user->actor);
26         xs *people_url = xs_fmt("%s/people", user->actor);
27@@ -957,6 +968,7 @@ static xs_html *html_user_body(snac *user, int read_only)
28             xs_html_tag("a",
29                 xs_html_attr("href", people_url),
30                 xs_html_text(L("people"))),
31+            pending_follow_count,
32             xs_html_text(" - "),
33             xs_html_tag("a",
34                 xs_html_attr("href", instance_url),
M snac.h
+1, -0
1@@ -159,6 +159,7 @@ int pending_check(snac *user, const char *actor);
2 xs_dict *pending_get(snac *user, const char *actor);
3 void pending_del(snac *user, const char *actor);
4 xs_list *pending_list(snac *user);
5+int pending_count(snac *user);
6 
7 double timeline_mtime(snac *snac);
8 int timeline_touch(snac *snac);