Skip to content

Commit 0a201f4

Browse files
committed
Revert "Don't do a full page load when clicking the follow button (go-gitea#28872)"
This reverts commit 1df06e3.
1 parent 1df06e3 commit 0a201f4

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

routers/web/user/profile.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"code.gitea.io/gitea/models/db"
1515
repo_model "code.gitea.io/gitea/models/repo"
1616
user_model "code.gitea.io/gitea/models/user"
17-
"code.gitea.io/gitea/modules/base"
1817
"code.gitea.io/gitea/modules/context"
1918
"code.gitea.io/gitea/modules/git"
2019
"code.gitea.io/gitea/modules/log"
@@ -27,10 +26,6 @@ import (
2726
shared_user "code.gitea.io/gitea/routers/web/shared/user"
2827
)
2928

30-
const (
31-
tplProfileBigAvatar base.TplName = "shared/user/profile_big_avatar"
32-
)
33-
3429
// OwnerProfile render profile page for a user or a organization (aka, repo owner)
3530
func OwnerProfile(ctx *context.Context) {
3631
if strings.Contains(ctx.Req.Header.Get("Accept"), "application/rss+xml") {
@@ -314,10 +309,8 @@ func Action(ctx *context.Context) {
314309

315310
if err != nil {
316311
log.Error("Failed to apply action %q: %v", ctx.FormString("action"), err)
317-
ctx.Error(http.StatusBadRequest, fmt.Sprintf("Action %q failed", ctx.FormString("action")))
312+
ctx.JSONError(fmt.Sprintf("Action %q failed", ctx.FormString("action")))
318313
return
319314
}
320-
321-
shared_user.PrepareContextForProfileBigAvatar(ctx)
322-
ctx.HTML(http.StatusOK, tplProfileBigAvatar)
315+
ctx.JSONOK()
323316
}

templates/shared/user/profile_big_avatar.tmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div id="profile-avatar-card" class="ui card">
1+
<div class="ui card">
22
<div id="profile-avatar" class="content gt-df">
33
{{if eq .SignedUserID .ContextUser.ID}}
44
<a class="image" href="{{AppSubUrl}}/user/settings" data-tooltip-content="{{ctx.Locale.Tr "user.change_avatar"}}">
@@ -110,13 +110,13 @@
110110
</li>
111111
{{end}}
112112
{{if and .IsSigned (ne .SignedUserID .ContextUser.ID)}}
113-
<li class="follow" hx-headers='{"x-csrf-token": "{{.CsrfToken}}"}' hx-target="#profile-avatar-card" hx-swap="outerHTML">
113+
<li class="follow">
114114
{{if $.IsFollowing}}
115-
<button hx-post="{{.ContextUser.HomeLink}}?action=unfollow" class="ui basic red button">
115+
<button class="ui basic red button link-action" data-url="{{.ContextUser.HomeLink}}?action=unfollow">
116116
{{svg "octicon-person"}} {{ctx.Locale.Tr "user.unfollow"}}
117117
</button>
118118
{{else}}
119-
<button hx-post="{{.ContextUser.HomeLink}}?action=follow" class="ui basic primary button">
119+
<button class="ui basic primary button link-action" data-url="{{.ContextUser.HomeLink}}?action=follow">
120120
{{svg "octicon-person"}} {{ctx.Locale.Tr "user.follow"}}
121121
</button>
122122
{{end}}

0 commit comments

Comments
 (0)