From 655a448adb0d861a15f6e7443c879928fd654f20 Mon Sep 17 00:00:00 2001 From: Paul Martin Date: Tue, 24 Dec 2024 20:35:58 +0000 Subject: mastoapi: implement timeline min_id --- mastoapi.c | 15 +++++++++++++-- 1 file 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); -- cgit v1.2.3