diff options
| author | 2025-05-18 08:23:48 +0200 | |
|---|---|---|
| committer | 2025-05-18 08:23:48 +0200 | |
| commit | ee84140ecceb07dad8ea36cc5aa29b91bbb48a56 (patch) | |
| tree | 077e8defca025ed364741a10b7557c02c554ab0f | |
| parent | mastoapi: Also process the types[] argument in notifications. (diff) | |
| download | snac2-ee84140ecceb07dad8ea36cc5aa29b91bbb48a56.tar.gz snac2-ee84140ecceb07dad8ea36cc5aa29b91bbb48a56.tar.xz snac2-ee84140ecceb07dad8ea36cc5aa29b91bbb48a56.zip | |
Added a pending follow request count next to the "people" link.
| -rw-r--r-- | data.c | 10 | ||||
| -rw-r--r-- | html.c | 12 | ||||
| -rw-r--r-- | snac.h | 1 |
3 files changed, 23 insertions, 0 deletions
| @@ -1335,6 +1335,16 @@ xs_list *pending_list(snac *user) | |||
| 1335 | } | 1335 | } |
| 1336 | 1336 | ||
| 1337 | 1337 | ||
| 1338 | int pending_count(snac *user) | ||
| 1339 | /* returns the number of pending follow confirmations */ | ||
| 1340 | { | ||
| 1341 | xs *spec = xs_fmt("%s/pending/""*.json", user->basedir); | ||
| 1342 | xs *l = xs_glob(spec, 0, 0); | ||
| 1343 | |||
| 1344 | return xs_list_len(l); | ||
| 1345 | } | ||
| 1346 | |||
| 1347 | |||
| 1338 | /** timeline **/ | 1348 | /** timeline **/ |
| 1339 | 1349 | ||
| 1340 | double timeline_mtime(snac *snac) | 1350 | double timeline_mtime(snac *snac) |
| @@ -923,7 +923,9 @@ static xs_html *html_user_body(snac *user, int read_only) | |||
| 923 | } | 923 | } |
| 924 | else { | 924 | else { |
| 925 | int n_len = notify_new_num(user); | 925 | int n_len = notify_new_num(user); |
| 926 | int p_len = pending_count(user); | ||
| 926 | xs_html *notify_count = NULL; | 927 | xs_html *notify_count = NULL; |
| 928 | xs_html *pending_follow_count = NULL; | ||
| 927 | 929 | ||
| 928 | /* show the number of new notifications, if there are any */ | 930 | /* show the number of new notifications, if there are any */ |
| 929 | if (n_len) { | 931 | if (n_len) { |
| @@ -935,6 +937,15 @@ static xs_html *html_user_body(snac *user, int read_only) | |||
| 935 | else | 937 | else |
| 936 | notify_count = xs_html_text(""); | 938 | notify_count = xs_html_text(""); |
| 937 | 939 | ||
| 940 | if (p_len) { | ||
| 941 | xs *s = xs_fmt(" %d ", p_len); | ||
| 942 | pending_follow_count = xs_html_tag("sup", | ||
| 943 | xs_html_attr("style", "background-color: red; color: white;"), | ||
| 944 | xs_html_text(s)); | ||
| 945 | } | ||
| 946 | else | ||
| 947 | pending_follow_count = xs_html_text(""); | ||
| 948 | |||
| 938 | xs *admin_url = xs_fmt("%s/admin", user->actor); | 949 | xs *admin_url = xs_fmt("%s/admin", user->actor); |
| 939 | xs *notify_url = xs_fmt("%s/notifications", user->actor); | 950 | xs *notify_url = xs_fmt("%s/notifications", user->actor); |
| 940 | xs *people_url = xs_fmt("%s/people", user->actor); | 951 | xs *people_url = xs_fmt("%s/people", user->actor); |
| @@ -957,6 +968,7 @@ static xs_html *html_user_body(snac *user, int read_only) | |||
| 957 | xs_html_tag("a", | 968 | xs_html_tag("a", |
| 958 | xs_html_attr("href", people_url), | 969 | xs_html_attr("href", people_url), |
| 959 | xs_html_text(L("people"))), | 970 | xs_html_text(L("people"))), |
| 971 | pending_follow_count, | ||
| 960 | xs_html_text(" - "), | 972 | xs_html_text(" - "), |
| 961 | xs_html_tag("a", | 973 | xs_html_tag("a", |
| 962 | xs_html_attr("href", instance_url), | 974 | xs_html_attr("href", instance_url), |
| @@ -159,6 +159,7 @@ int pending_check(snac *user, const char *actor); | |||
| 159 | xs_dict *pending_get(snac *user, const char *actor); | 159 | xs_dict *pending_get(snac *user, const char *actor); |
| 160 | void pending_del(snac *user, const char *actor); | 160 | void pending_del(snac *user, const char *actor); |
| 161 | xs_list *pending_list(snac *user); | 161 | xs_list *pending_list(snac *user); |
| 162 | int pending_count(snac *user); | ||
| 162 | 163 | ||
| 163 | double timeline_mtime(snac *snac); | 164 | double timeline_mtime(snac *snac); |
| 164 | int timeline_touch(snac *snac); | 165 | int timeline_touch(snac *snac); |