From 677eea9c225ac897cda9e7428a89e716915d3382 Mon Sep 17 00:00:00 2001 From: Alessio Date: Fri, 11 Aug 2023 01:44:10 -0300 Subject: [PATCH] Fix bug causing crash at bottom of a feed --- pkg/persistence/compound_ssf_queries.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pkg/persistence/compound_ssf_queries.go b/pkg/persistence/compound_ssf_queries.go index f0ed66f..38fb160 100644 --- a/pkg/persistence/compound_ssf_queries.go +++ b/pkg/persistence/compound_ssf_queries.go @@ -195,8 +195,6 @@ func (p Profile) NextPage(c Cursor) (Feed, error) { // Run the query var results []CursorResult - fmt.Printf("Query: %s\n", q) - fmt.Printf("Args: %#v\n", bind_values) err := p.DB.Select(&results, q, bind_values...) if err != nil { panic(err) @@ -212,19 +210,18 @@ func (p Profile) NextPage(c Cursor) (Feed, error) { ret.Items = append(ret.Items, FeedItem{TweetID: val.Tweet.ID, RetweetID: val.Retweet.RetweetID}) } - // Set the new cursor position - last_item := results[len(results)-1] - next_cursor_value := c.SortOrder.NextCursorValue(last_item) p.fill_content(&ret.TweetTrove) ret.CursorBottom = c - ret.CursorBottom.CursorValue = next_cursor_value + // Set the new cursor position and value if len(results) < c.PageSize { ret.CursorBottom.CursorPosition = CURSOR_END } else { ret.CursorBottom.CursorPosition = CURSOR_MIDDLE + last_item := results[len(results)-1] + ret.CursorBottom.CursorValue = c.SortOrder.NextCursorValue(last_item) } return ret, nil