Skip to content

Commit 122f96f

Browse files
brechtvltechknowlogick
authored andcommitted
Fix pagination issues on user profile page
1 parent c93cd3d commit 122f96f

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

routers/web/user/profile.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ func Profile(ctx *context.Context) {
119119
page = 1
120120
}
121121

122+
pagingNum := setting.UI.User.RepoPagingNum
123+
if tab == "activity" {
124+
pagingNum = setting.UI.FeedPagingNum
125+
}
126+
122127
topicOnly := ctx.FormBool("topic")
123128

124129
var (
@@ -164,7 +169,7 @@ func Profile(ctx *context.Context) {
164169
switch tab {
165170
case "followers":
166171
items, count, err := user_model.GetUserFollowers(ctx, ctx.ContextUser, ctx.Doer, db.ListOptions{
167-
PageSize: setting.UI.User.RepoPagingNum,
172+
PageSize: pagingNum,
168173
Page: page,
169174
})
170175
if err != nil {
@@ -176,7 +181,7 @@ func Profile(ctx *context.Context) {
176181
total = int(count)
177182
case "following":
178183
items, count, err := user_model.GetUserFollowing(ctx, ctx.ContextUser, ctx.Doer, db.ListOptions{
179-
PageSize: setting.UI.User.RepoPagingNum,
184+
PageSize: pagingNum,
180185
Page: page,
181186
})
182187
if err != nil {
@@ -187,15 +192,16 @@ func Profile(ctx *context.Context) {
187192

188193
total = int(count)
189194
case "activity":
195+
date := ctx.FormString("date")
190196
items, count, err := activities_model.GetFeeds(ctx, activities_model.GetFeedsOptions{
191197
RequestedUser: ctx.ContextUser,
192198
Actor: ctx.Doer,
193199
IncludePrivate: showPrivate,
194200
OnlyPerformedBy: true,
195201
IncludeDeleted: false,
196-
Date: ctx.FormString("date"),
202+
Date: date,
197203
ListOptions: db.ListOptions{
198-
PageSize: setting.UI.FeedPagingNum,
204+
PageSize: pagingNum,
199205
Page: page,
200206
},
201207
})
@@ -204,13 +210,14 @@ func Profile(ctx *context.Context) {
204210
return
205211
}
206212
ctx.Data["Feeds"] = items
213+
ctx.Data["Date"] = date
207214

208215
total = int(count)
209216
case "stars":
210217
ctx.Data["PageIsProfileStarList"] = true
211218
repos, count, err = repo_model.SearchRepository(ctx, &repo_model.SearchRepoOptions{
212219
ListOptions: db.ListOptions{
213-
PageSize: setting.UI.User.RepoPagingNum,
220+
PageSize: pagingNum,
214221
Page: page,
215222
},
216223
Actor: ctx.Doer,
@@ -242,7 +249,7 @@ func Profile(ctx *context.Context) {
242249
case "watching":
243250
repos, count, err = repo_model.SearchRepository(ctx, &repo_model.SearchRepoOptions{
244251
ListOptions: db.ListOptions{
245-
PageSize: setting.UI.User.RepoPagingNum,
252+
PageSize: pagingNum,
246253
Page: page,
247254
},
248255
Actor: ctx.Doer,
@@ -264,7 +271,7 @@ func Profile(ctx *context.Context) {
264271
default:
265272
repos, count, err = repo_model.SearchRepository(ctx, &repo_model.SearchRepoOptions{
266273
ListOptions: db.ListOptions{
267-
PageSize: setting.UI.User.RepoPagingNum,
274+
PageSize: pagingNum,
268275
Page: page,
269276
},
270277
Actor: ctx.Doer,
@@ -287,12 +294,15 @@ func Profile(ctx *context.Context) {
287294
ctx.Data["Repos"] = repos
288295
ctx.Data["Total"] = total
289296

290-
pager := context.NewPagination(total, setting.UI.User.RepoPagingNum, page, 5)
297+
pager := context.NewPagination(total, pagingNum, page, 5)
291298
pager.SetDefaultParams(ctx)
292299
pager.AddParam(ctx, "tab", "TabName")
293300
if tab != "followers" && tab != "following" && tab != "activity" && tab != "projects" {
294301
pager.AddParam(ctx, "language", "Language")
295302
}
303+
if tab == "activity" {
304+
pager.AddParam(ctx, "date", "Date")
305+
}
296306
ctx.Data["Page"] = pager
297307
ctx.Data["IsPackageEnabled"] = setting.Packages.Enabled
298308
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled

0 commit comments

Comments
 (0)