aboutsummaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorr <r@freesoftwareextremist.com>2021-01-23 07:02:12 +0000
committerr <r@freesoftwareextremist.com>2021-01-23 07:02:12 +0000
commiteca0366c21c94f7cbf6d1b701dd31be8ee81abc7 (patch)
tree527e5cf98768fb8640ee8bef82ed5c771183bd8e /service
parentace344b66ac42a3fa80c8e0dffb485dbeb88ff92 (diff)
downloadbloat-eca0366c21c94f7cbf6d1b701dd31be8ee81abc7.tar.gz
bloat-eca0366c21c94f7cbf6d1b701dd31be8ee81abc7.zip
Simplify timeline pagination
Diffstat (limited to 'service')
-rw-r--r--service/service.go23
1 files changed, 2 insertions, 21 deletions
diff --git a/service/service.go b/service/service.go
index 01306d0..f376fde 100644
--- a/service/service.go
+++ b/service/service.go
@@ -195,31 +195,12 @@ func (s *service) TimelinePage(c *client, tType string,
}
}
- if len(maxID) > 0 && len(statuses) > 0 {
+ if (len(maxID) > 0 || len(minID) > 0) && len(statuses) > 0 {
prevLink = fmt.Sprintf("/timeline/%s?min_id=%s", tType,
statuses[0].ID)
}
- if len(minID) > 0 && len(pg.MinID) > 0 {
- newPg := &mastodon.Pagination{MinID: pg.MinID, Limit: 20}
- newStatuses, err := c.GetTimelineHome(ctx, newPg)
- if err != nil {
- return err
- }
- newLen := len(newStatuses)
- if newLen == 20 {
- prevLink = fmt.Sprintf("/timeline/%s?min_id=%s",
- tType, pg.MinID)
- } else {
- i := 20 - newLen - 1
- if len(statuses) > i {
- prevLink = fmt.Sprintf("/timeline/%s?min_id=%s",
- tType, statuses[i].ID)
- }
- }
- }
-
- if len(pg.MaxID) > 0 && len(statuses) == 20 {
+ if len(minID) > 0 || (len(pg.MaxID) > 0 && len(statuses) == 20) {
nextLink = fmt.Sprintf("/timeline/%s?max_id=%s", tType, pg.MaxID)
}