refactor: pagination/pager (#39162)

This commit is contained in:
wxiaoguang
2026-08-29 08:20:46 +02:00
committed by GitHub
parent 9297205f2c
commit fedf219e77
42 changed files with 133 additions and 131 deletions
+3 -7
View File
@@ -128,9 +128,7 @@ func Dashboard(ctx *context.Context) {
// FIXME: UNLIMITE-PAGING-ONE-MORE-ROW: here is still an edge case: when curRows==pagingNum, then the "next page" will be an empty page.
// Ideally we should query one more row to determine if there is really a next page, but it's impossible in current framework.
pager := context.NewPagination(count, pageSize, page, 5).WithUnlimitedPaging(len(feeds), len(feeds) == pageSize)
pager.AddParamFromRequest(ctx.Req)
pager := context.NewPagerBuilder(ctx).TotalCount(count).PerPageLimit(pageSize).CurPage(page).Build().WithUnlimitedPaging(len(feeds), len(feeds) == pageSize)
ctx.Data["Page"] = pager
ctx.Data["Feeds"] = feeds
@@ -321,8 +319,7 @@ func Milestones(ctx *context.Context) {
ctx.Data["RepoIDs"] = repoIDs
ctx.Data["IsShowClosed"] = isShowClosed
pager := context.NewPagination(pagerCount, setting.UI.IssuePagingNum, page, 5)
pager.AddParamFromRequest(ctx.Req)
pager := context.NewPagerBuilder(ctx).TotalCount(pagerCount).PerPageLimit(setting.UI.IssuePagingNum).CurPage(page).Build()
ctx.Data["Page"] = pager
ctx.HTML(http.StatusOK, tplMilestones)
@@ -629,8 +626,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
ctx.Data["State"] = "open"
}
pager := context.NewPagination(shownIssues, setting.UI.IssuePagingNum, page, 5)
pager.AddParamFromRequest(ctx.Req)
pager := context.NewPagerBuilder(ctx).TotalCount(shownIssues).PerPageLimit(setting.UI.IssuePagingNum).CurPage(page).Build()
ctx.Data["Page"] = pager
ctx.HTML(http.StatusOK, tplIssues)