Added a limit to the number of items on the landing page following tab
This commit is contained in:
parent
0497b262f4
commit
1163640121
|
@ -16,7 +16,12 @@ func FollowingTest(c *RequestContext) ResponseData {
|
|||
lineageBuilder := models.MakeSubforumLineageBuilder(subforumTree)
|
||||
c.Perf.EndBlock()
|
||||
|
||||
timelineItems, err := FetchFollowTimelineForUser(c, c.Conn, c.CurrentUser, lineageBuilder)
|
||||
timelineItems, err := FetchFollowTimelineForUser(
|
||||
c, c.Conn,
|
||||
c.CurrentUser,
|
||||
lineageBuilder,
|
||||
FollowTimelineQuery{},
|
||||
)
|
||||
if err != nil {
|
||||
return c.ErrorResponse(http.StatusInternalServerError, err)
|
||||
}
|
||||
|
|
|
@ -52,7 +52,14 @@ func Index(c *RequestContext) ResponseData {
|
|||
var newsItems []templates.TimelineItem
|
||||
|
||||
if c.CurrentUser != nil {
|
||||
followingItems, err = FetchFollowTimelineForUser(c, c.Conn, c.CurrentUser, lineageBuilder)
|
||||
followingItems, err = FetchFollowTimelineForUser(
|
||||
c, c.Conn,
|
||||
c.CurrentUser,
|
||||
lineageBuilder,
|
||||
FollowTimelineQuery{
|
||||
Limit: 100,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
c.Logger.Warn().Err(err).Msg("failed to fetch following feed")
|
||||
}
|
||||
|
|
|
@ -20,7 +20,12 @@ import (
|
|||
"git.handmade.network/hmn/hmn/src/templates"
|
||||
)
|
||||
|
||||
func FetchFollowTimelineForUser(ctx context.Context, conn db.ConnOrTx, user *models.User, lineageBuilder *models.SubforumLineageBuilder) ([]templates.TimelineItem, error) {
|
||||
type FollowTimelineQuery struct {
|
||||
Offset int
|
||||
Limit int
|
||||
}
|
||||
|
||||
func FetchFollowTimelineForUser(ctx context.Context, conn db.ConnOrTx, user *models.User, lineageBuilder *models.SubforumLineageBuilder, q FollowTimelineQuery) ([]templates.TimelineItem, error) {
|
||||
perf := perf.ExtractPerf(ctx)
|
||||
|
||||
perf.StartBlock("FOLLOW", "Assemble follow data")
|
||||
|
@ -50,6 +55,8 @@ func FetchFollowTimelineForUser(ctx context.Context, conn db.ConnOrTx, user *mod
|
|||
timelineItems, err = FetchTimeline(ctx, conn, user, lineageBuilder, hmndata.TimelineQuery{
|
||||
OwnerIDs: userIDs,
|
||||
ProjectIDs: projectIDs,
|
||||
Offset: q.Offset,
|
||||
Limit: q.Limit,
|
||||
})
|
||||
}
|
||||
perf.EndBlock()
|
||||
|
|
Loading…
Reference in New Issue