diff options
author | Lauris BH <lauris@nix.lv> | 2020-02-09 22:18:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-09 22:18:01 +0200 |
commit | fe00886befebca6e532dfc49813c3273c4bfff68 (patch) | |
tree | f7549d49a131409e502e59bf4e522706f48b8f96 /routers/user/profile.go | |
parent | e273817154e98b7b675e43e97cd17f48a603cf9e (diff) | |
download | gitea-fe00886befebca6e532dfc49813c3273c4bfff68.tar.gz gitea-fe00886befebca6e532dfc49813c3273c4bfff68.zip |
Fix followers and following tabs in profile (#10202)
Diffstat (limited to 'routers/user/profile.go')
-rw-r--r-- | routers/user/profile.go | 56 |
1 files changed, 24 insertions, 32 deletions
diff --git a/routers/user/profile.go b/routers/user/profile.go index 808ce382c7..a151884d76 100644 --- a/routers/user/profile.go +++ b/routers/user/profile.go @@ -11,16 +11,10 @@ import ( "strings" "code.gitea.io/gitea/models" - "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/routers/org" - "code.gitea.io/gitea/routers/repo" -) - -const ( - tplFollowers base.TplName = "user/meta/followers" ) // GetUserByName get user by name @@ -159,6 +153,30 @@ func Profile(ctx *context.Context) { keyword := strings.Trim(ctx.Query("q"), " ") ctx.Data["Keyword"] = keyword switch tab { + case "followers": + items, err := ctxUser.GetFollowers(models.ListOptions{ + PageSize: setting.UI.User.RepoPagingNum, + Page: page, + }) + if err != nil { + ctx.ServerError("GetFollowers", err) + return + } + ctx.Data["Cards"] = items + + total = ctxUser.NumFollowers + case "following": + items, err := ctxUser.GetFollowing(models.ListOptions{ + PageSize: setting.UI.User.RepoPagingNum, + Page: page, + }) + if err != nil { + ctx.ServerError("GetFollowing", err) + return + } + ctx.Data["Cards"] = items + + total = ctxUser.NumFollowing case "activity": retrieveFeeds(ctx, models.GetFeedsOptions{RequestedUser: ctxUser, Actor: ctx.User, @@ -226,32 +244,6 @@ func Profile(ctx *context.Context) { ctx.HTML(200, tplProfile) } -// Followers render user's followers page -func Followers(ctx *context.Context) { - u := GetUserByParams(ctx) - if ctx.Written() { - return - } - ctx.Data["Title"] = u.DisplayName() - ctx.Data["CardsTitle"] = ctx.Tr("user.followers") - ctx.Data["PageIsFollowers"] = true - ctx.Data["Owner"] = u - repo.RenderUserCards(ctx, u.NumFollowers, u.GetFollowers, tplFollowers) -} - -// Following render user's followering page -func Following(ctx *context.Context) { - u := GetUserByParams(ctx) - if ctx.Written() { - return - } - ctx.Data["Title"] = u.DisplayName() - ctx.Data["CardsTitle"] = ctx.Tr("user.following") - ctx.Data["PageIsFollowing"] = true - ctx.Data["Owner"] = u - repo.RenderUserCards(ctx, u.NumFollowing, u.GetFollowing, tplFollowers) -} - // Action response for follow/unfollow user request func Action(ctx *context.Context) { u := GetUserByParams(ctx) |