Skip to content

Commit

Permalink
fix: Only return null cursor when post list is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
snorremd committed Jan 18, 2025
1 parent 1553043 commit 13add83
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions feeds/feeds.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 13add83

Please sign in to comment.