mirror of
https://git.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-28 22:51:27 +00:00
Fix timeline pagination
This commit is contained in:
parent
1939d120cd
commit
c18a1be21a
|
@ -5,6 +5,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -243,7 +244,7 @@ func (svc *service) ServeTimelinePage(ctx context.Context, client io.Writer,
|
||||||
|
|
||||||
if len(maxID) > 0 && len(statuses) > 0 {
|
if len(maxID) > 0 && len(statuses) > 0 {
|
||||||
hasPrev = true
|
hasPrev = true
|
||||||
prevLink = "/timeline?min_id=" + statuses[0].ID
|
prevLink = fmt.Sprintf("/timeline/$s?min_id=%s", timelineType, statuses[0].ID)
|
||||||
}
|
}
|
||||||
if len(minID) > 0 && len(pg.MinID) > 0 {
|
if len(minID) > 0 && len(pg.MinID) > 0 {
|
||||||
newStatuses, err := c.GetTimelineHome(ctx, &mastodon.Pagination{MinID: pg.MinID, Limit: 20})
|
newStatuses, err := c.GetTimelineHome(ctx, &mastodon.Pagination{MinID: pg.MinID, Limit: 20})
|
||||||
|
@ -253,18 +254,18 @@ func (svc *service) ServeTimelinePage(ctx context.Context, client io.Writer,
|
||||||
newStatusesLen := len(newStatuses)
|
newStatusesLen := len(newStatuses)
|
||||||
if newStatusesLen == 20 {
|
if newStatusesLen == 20 {
|
||||||
hasPrev = true
|
hasPrev = true
|
||||||
prevLink = "/timeline?min_id=" + pg.MinID
|
prevLink = fmt.Sprintf("/timeline/%s?min_id=%s", timelineType, pg.MinID)
|
||||||
} else {
|
} else {
|
||||||
i := 20 - newStatusesLen - 1
|
i := 20 - newStatusesLen - 1
|
||||||
if len(statuses) > i {
|
if len(statuses) > i {
|
||||||
hasPrev = true
|
hasPrev = true
|
||||||
prevLink = "/timeline?min_id=" + statuses[i].ID
|
prevLink = fmt.Sprintf("/timeline/%s?min_id=%s", timelineType, statuses[i].ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(pg.MaxID) > 0 {
|
if len(pg.MaxID) > 0 {
|
||||||
hasNext = true
|
hasNext = true
|
||||||
nextLink = "/timeline?max_id=" + pg.MaxID
|
nextLink = fmt.Sprintf("/timeline/%s?max_id=%s", timelineType, pg.MaxID)
|
||||||
}
|
}
|
||||||
|
|
||||||
postContext := model.PostContext{
|
postContext := model.PostContext{
|
||||||
|
|
Loading…
Reference in a new issue