aboutsummaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
authorPaul Martin <pm@nowster.org.uk>2024-12-24 20:35:58 +0000
committerPaul Martin <pm@nowster.org.uk>2024-12-26 16:51:27 +0000
commit655a448adb0d861a15f6e7443c879928fd654f20 (patch)
treea9ecbcfb5da56d8f3cebdec781a52330ea8a38d9 /mastoapi.c
parent2384a5409bc3a8a6ede4bf33bb1584a6bfae39af (diff)
mastoapi: implement timeline min_id
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 09e18a1..853d74b 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -1348,7 +1348,7 @@ xs_list *mastoapi_timeline(snac *user, const xs_dict *args, const char *index_fn
if (limit == 0)
limit = 20;
- if (min_id == NULL && index_desc_first(f, md5, 0)) {
+ if (index_desc_first(f, md5, 0)) {
do {
xs *msg = NULL;
@@ -1366,6 +1366,11 @@ xs_list *mastoapi_timeline(snac *user, const xs_dict *args, const char *index_fn
break;
}
+ if (min_id) {
+ if (strcmp(md5, MID_TO_MD5(min_id)) == 0)
+ break;
+ }
+
/* get the entry */
if (user) {
if (!valid_status(timeline_get_by_md5(user, md5, &msg)))
@@ -1435,8 +1440,14 @@ xs_list *mastoapi_timeline(snac *user, const xs_dict *args, const char *index_fn
out = xs_list_append(out, st);
cnt++;
}
+ if (min_id) {
+ while (cnt > limit) {
+ out = xs_list_del(out, 0);
+ cnt--;
+ }
+ }
- } while (cnt < limit && index_desc_next(f, md5));
+ } while ((min_id || (cnt < limit)) && index_desc_next(f, md5));
}
int more = index_desc_next(f, md5);