From 13add838d087e814dc17eaf0f3f39702d6f587f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Snorre=20Magnus=20Dav=C3=B8en?= Date: Sat, 18 Jan 2025 14:07:09 +0100 Subject: [PATCH] fix: Only return null cursor when post list is empty --- feeds/feeds.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/feeds/feeds.go b/feeds/feeds.go index 9755200..47fa8bd 100644 --- a/feeds/feeds.go +++ b/feeds/feeds.go @@ -29,12 +29,15 @@ func genericAlgo(reader *db.Reader, cursor string, limit int, languages []string var nextCursor *string nextCursor = nil - if len(posts) > limit { - posts = posts[:len(posts)-1] + if len(posts) > 0 { + if len(posts) > limit { + posts = posts[:len(posts)-1] + } parsed := strconv.FormatInt(posts[len(posts)-1].Id, 10) nextCursor = &parsed } + return &models.FeedResponse{ Feed: posts, Cursor: nextCursor,