commit 4e35b4b
default
·
2024-02-05 18:34:27 +0000 UTC
parent 67fbc68
Added paging to notify_list(), and use it in the notifications page.
4 files changed,
+8,
-8
M
data.c
+3,
-3
1@@ -2084,7 +2084,7 @@ xs_dict *notify_get(snac *snac, const char *id)
2 }
3
4
5-xs_list *notify_list(snac *snac)
6+xs_list *notify_list(snac *snac, int skip, int show)
7 /* returns a list of notification ids */
8 {
9 xs *idx = xs_fmt("%s/notify.idx", snac->basedir);
10@@ -2115,7 +2115,7 @@ xs_list *notify_list(snac *snac)
11 pthread_mutex_unlock(&data_mutex);
12 }
13
14- return index_list_desc(idx, 0, 64);
15+ return index_list_desc(idx, skip, show);
16 }
17
18
19@@ -2123,7 +2123,7 @@ int notify_new_num(snac *snac)
20 /* counts the number of new notifications */
21 {
22 xs *t = notify_check_time(snac, 0);
23- xs *lst = notify_list(snac);
24+ xs *lst = notify_list(snac, 0, XS_ALL);
25 int cnt = 0;
26
27 xs_list *p = lst;
M
html.c
+3,
-3
1@@ -2135,9 +2135,9 @@ xs_str *html_people(snac *user)
2 }
3
4
5-xs_str *html_notifications(snac *user)
6+xs_str *html_notifications(snac *user, int skip, int show)
7 {
8- xs *n_list = notify_list(user);
9+ xs *n_list = notify_list(user, skip, show);
10 xs *n_time = notify_check_time(user, 0);
11
12 xs_html *body = html_user_body(user, 0);
13@@ -2428,7 +2428,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
14 status = 401;
15 }
16 else {
17- *body = html_notifications(&snac);
18+ *body = html_notifications(&snac, skip, show);
19 *b_size = strlen(*body);
20 status = 200;
21 }
+1,
-1
1@@ -1542,7 +1542,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
2 else
3 if (strcmp(cmd, "/v1/notifications") == 0) { /** **/
4 if (logged_in) {
5- xs *l = notify_list(&snac1);
6+ xs *l = notify_list(&snac1, 0, 64);
7 xs *out = xs_list_new();
8 xs_list *p = l;
9 xs_dict *v;
M
snac.h
+1,
-1
1@@ -188,7 +188,7 @@ void notify_add(snac *snac, const char *type, const char *utype,
2 const char *actor, const char *objid);
3 xs_dict *notify_get(snac *snac, const char *id);
4 int notify_new_num(snac *snac);
5-xs_list *notify_list(snac *snac);
6+xs_list *notify_list(snac *snac, int skip, int show);
7 void notify_clear(snac *snac);
8
9 void inbox_add(const char *inbox);