mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 05:15:04 +00:00
Added paging to notify_list(), and use it in the notifications page.
This commit is contained in:
parent
67fbc6816b
commit
4e35b4b865
4 changed files with 8 additions and 8 deletions
6
data.c
6
data.c
|
@ -2084,7 +2084,7 @@ xs_dict *notify_get(snac *snac, const char *id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
xs_list *notify_list(snac *snac)
|
xs_list *notify_list(snac *snac, int skip, int show)
|
||||||
/* returns a list of notification ids */
|
/* returns a list of notification ids */
|
||||||
{
|
{
|
||||||
xs *idx = xs_fmt("%s/notify.idx", snac->basedir);
|
xs *idx = xs_fmt("%s/notify.idx", snac->basedir);
|
||||||
|
@ -2115,7 +2115,7 @@ xs_list *notify_list(snac *snac)
|
||||||
pthread_mutex_unlock(&data_mutex);
|
pthread_mutex_unlock(&data_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return index_list_desc(idx, 0, 64);
|
return index_list_desc(idx, skip, show);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2123,7 +2123,7 @@ int notify_new_num(snac *snac)
|
||||||
/* counts the number of new notifications */
|
/* counts the number of new notifications */
|
||||||
{
|
{
|
||||||
xs *t = notify_check_time(snac, 0);
|
xs *t = notify_check_time(snac, 0);
|
||||||
xs *lst = notify_list(snac);
|
xs *lst = notify_list(snac, 0, XS_ALL);
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
|
|
||||||
xs_list *p = lst;
|
xs_list *p = lst;
|
||||||
|
|
6
html.c
6
html.c
|
@ -2135,9 +2135,9 @@ xs_str *html_people(snac *user)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
xs_str *html_notifications(snac *user)
|
xs_str *html_notifications(snac *user, int skip, int show)
|
||||||
{
|
{
|
||||||
xs *n_list = notify_list(user);
|
xs *n_list = notify_list(user, skip, show);
|
||||||
xs *n_time = notify_check_time(user, 0);
|
xs *n_time = notify_check_time(user, 0);
|
||||||
|
|
||||||
xs_html *body = html_user_body(user, 0);
|
xs_html *body = html_user_body(user, 0);
|
||||||
|
@ -2428,7 +2428,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
|
||||||
status = 401;
|
status = 401;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*body = html_notifications(&snac);
|
*body = html_notifications(&snac, skip, show);
|
||||||
*b_size = strlen(*body);
|
*b_size = strlen(*body);
|
||||||
status = 200;
|
status = 200;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1542,7 +1542,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
||||||
else
|
else
|
||||||
if (strcmp(cmd, "/v1/notifications") == 0) { /** **/
|
if (strcmp(cmd, "/v1/notifications") == 0) { /** **/
|
||||||
if (logged_in) {
|
if (logged_in) {
|
||||||
xs *l = notify_list(&snac1);
|
xs *l = notify_list(&snac1, 0, 64);
|
||||||
xs *out = xs_list_new();
|
xs *out = xs_list_new();
|
||||||
xs_list *p = l;
|
xs_list *p = l;
|
||||||
xs_dict *v;
|
xs_dict *v;
|
||||||
|
|
2
snac.h
2
snac.h
|
@ -188,7 +188,7 @@ void notify_add(snac *snac, const char *type, const char *utype,
|
||||||
const char *actor, const char *objid);
|
const char *actor, const char *objid);
|
||||||
xs_dict *notify_get(snac *snac, const char *id);
|
xs_dict *notify_get(snac *snac, const char *id);
|
||||||
int notify_new_num(snac *snac);
|
int notify_new_num(snac *snac);
|
||||||
xs_list *notify_list(snac *snac);
|
xs_list *notify_list(snac *snac, int skip, int show);
|
||||||
void notify_clear(snac *snac);
|
void notify_clear(snac *snac);
|
||||||
|
|
||||||
void inbox_add(const char *inbox);
|
void inbox_add(const char *inbox);
|
||||||
|
|
Loading…
Reference in a new issue