From e9c69c8eac82090c18f398eec29620b4e086ccbd Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Sun, 17 Apr 2022 00:15:35 +0200 Subject: [PATCH] Problem: error when paging without items Solution: check if items are available --- pkg/timeline/postgres.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/timeline/postgres.go b/pkg/timeline/postgres.go index b4ddac9..9d43fda 100644 --- a/pkg/timeline/postgres.go +++ b/pkg/timeline/postgres.go @@ -180,8 +180,7 @@ WHERE "channel_id" = $1 return tl, err } - // TODO: should only be set of there are more items available - if hasMoreBefore(conn, tl.Items[0].Published) { + if len(tl.Items) > 0 && hasMoreBefore(conn, tl.Items[0].Published) { tl.Paging.Before = tl.Items[0].Published } if hasMoreAfter(conn, last) {