Better number for UserCards pagination

This commit is contained in:
0ko 2024-03-07 13:30:12 +05:00
parent d759bec64f
commit 498a3f988d
2 changed files with 10 additions and 6 deletions

View file

@ -22,8 +22,12 @@ const (
var RecognisedRepositoryDownloadOrCloneMethods = []string{"download-zip", "download-targz", "download-bundle", "vscode-clone", "vscodium-clone", "cite"}
// ItemsPerPage maximum items per page in forks, watchers and stars of a repo
const ItemsPerPage = 40
// MaxUserCardsPerPage sets maximum amount of watchers and stargazers shown per page
// those pages use 2 or 3 column layout, so the value should be divisible by 2 and 3
const MaxUserCardsPerPage = 36
// MaxForksPerPage sets maximum amount of forks shown per page
const MaxForksPerPage = 40
// Repository settings
var (

View file

@ -1127,12 +1127,12 @@ func RenderUserCards(ctx *context.Context, total int, getter func(opts db.ListOp
if page <= 0 {
page = 1
}
pager := context.NewPagination(total, setting.ItemsPerPage, page, 5)
pager := context.NewPagination(total, setting.MaxUserCardsPerPage, page, 5)
ctx.Data["Page"] = pager
items, err := getter(db.ListOptions{
Page: pager.Paginater.Current(),
PageSize: setting.ItemsPerPage,
PageSize: setting.MaxUserCardsPerPage,
})
if err != nil {
ctx.ServerError("getter", err)
@ -1173,12 +1173,12 @@ func Forks(ctx *context.Context) {
page = 1
}
pager := context.NewPagination(ctx.Repo.Repository.NumForks, setting.ItemsPerPage, page, 5)
pager := context.NewPagination(ctx.Repo.Repository.NumForks, setting.MaxForksPerPage, page, 5)
ctx.Data["Page"] = pager
forks, err := repo_model.GetForks(ctx, ctx.Repo.Repository, db.ListOptions{
Page: pager.Paginater.Current(),
PageSize: setting.ItemsPerPage,
PageSize: setting.MaxForksPerPage,
})
if err != nil {
ctx.ServerError("GetForks", err)