diff options
author | yp05327 <576951401@qq.com> | 2024-12-27 03:49:50 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-27 02:49:50 +0800 |
commit | 7bb7ba1b5b70eb9ad984eaeeabecc1dcc2a26eb9 (patch) | |
tree | de08464d806d2a968d69a9b7eb8feaa1083e18c1 /routers/web/shared | |
parent | 550abdbc2443209d6b2f4801c6e3c180b48d73bb (diff) | |
download | gitea-7bb7ba1b5b70eb9ad984eaeeabecc1dcc2a26eb9.tar.gz gitea-7bb7ba1b5b70eb9ad984eaeeabecc1dcc2a26eb9.zip |
Add `show more` organizations icon in user's profile (#32986)
Close #32952
# ⚠️ Doc update is required


------
⚠️This PR refuses to be cherry-picked by any forked projects without any
mentions.
---------
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'routers/web/shared')
-rw-r--r-- | routers/web/shared/user/header.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/routers/web/shared/user/header.go b/routers/web/shared/user/header.go index 4cb0592b4b..d388d2b5d9 100644 --- a/routers/web/shared/user/header.go +++ b/routers/web/shared/user/header.go @@ -61,11 +61,20 @@ func PrepareContextForProfileBigAvatar(ctx *context.Context) { orgs, err := db.Find[organization.Organization](ctx, organization.FindOrgOptions{ UserID: ctx.ContextUser.ID, IncludePrivate: showPrivate, + ListOptions: db.ListOptions{ + Page: 1, + // query one more results (without a separate counting) to see whether we need to add the "show more orgs" link + PageSize: setting.UI.User.OrgPagingNum + 1, + }, }) if err != nil { ctx.ServerError("FindOrgs", err) return } + if len(orgs) > setting.UI.User.OrgPagingNum { + orgs = orgs[:setting.UI.User.OrgPagingNum] + ctx.Data["ShowMoreOrgs"] = true + } ctx.Data["Orgs"] = orgs ctx.Data["HasOrgsVisible"] = organization.HasOrgsVisible(ctx, orgs, ctx.Doer) |