Skip to content

Commit ea0223e

Browse files
committed
fix
1 parent cd015d9 commit ea0223e

File tree

3 files changed

+5
-16
lines changed

3 files changed

+5
-16
lines changed

routers/web/user/home.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func Dashboard(ctx *context.Context) {
139139

140140
ctx.Data["Feeds"] = feeds
141141

142-
pager := context.NewPagination(int(count), setting.UI.FeedPagingNum, page, 5)
142+
pager := context.NewPagination(count, setting.UI.FeedPagingNum, page, 5)
143143
pager.AddParamFromRequest(ctx.Req)
144144
ctx.Data["Page"] = pager
145145

services/context/pagination.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type Pagination struct {
2121

2222
// NewPagination creates a new instance of the Pagination struct.
2323
// "pagingNum" is "page size" or "limit", "current" is "page"
24+
// total=-1 means only showing prev/next
2425
func NewPagination(total, pagingNum, current, numPages int) *Pagination {
2526
p := &Pagination{}
2627
p.Paginater = paginator.New(total, pagingNum, current, numPages)

services/feed/feed.go

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package feed
66
import (
77
"context"
88
"fmt"
9-
"math"
109

1110
activities_model "code.gitea.io/gitea/models/activities"
1211
"code.gitea.io/gitea/models/db"
@@ -16,28 +15,17 @@ import (
1615
user_model "code.gitea.io/gitea/models/user"
1716
"code.gitea.io/gitea/modules/cache"
1817
"code.gitea.io/gitea/modules/setting"
18+
"code.gitea.io/gitea/modules/util"
1919
)
2020

2121
func userFeedCacheKey(userID int64) string {
2222
return fmt.Sprintf("user_feed_%d", userID)
2323
}
2424

25-
func GetFeedsForDashboard(ctx context.Context, opts activities_model.GetFeedsOptions) (activities_model.ActionList, int64, error) {
25+
func GetFeedsForDashboard(ctx context.Context, opts activities_model.GetFeedsOptions) (activities_model.ActionList, int, error) {
2626
opts.DontCount = opts.RequestedTeam == nil && opts.Date == ""
2727
results, cnt, err := activities_model.GetFeeds(ctx, opts)
28-
if err != nil {
29-
return nil, 0, err
30-
}
31-
if !setting.UI.User.DashboardActivitiesPagination {
32-
return results, math.MaxInt32, nil
33-
}
34-
35-
if opts.DontCount {
36-
cnt, err = cache.GetInt64(userFeedCacheKey(opts.Actor.ID), func() (int64, error) {
37-
return activities_model.CountUserFeeds(ctx, opts.Actor.ID)
38-
})
39-
}
40-
return results, cnt, err
28+
return results, util.Iif(opts.DontCount, -1, int(cnt)), err
4129
}
4230

4331
// GetFeeds returns actions according to the provided options

0 commit comments

Comments
 (0)