Skip to content

Commit

Permalink
Revert "Don't do a full page load when clicking the follow button (go…
Browse files Browse the repository at this point in the history
…-gitea#28872)"

This reverts commit 1df06e3.
  • Loading branch information
6543 committed Jan 21, 2024
1 parent 1df06e3 commit 0a201f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
11 changes: 2 additions & 9 deletions routers/web/user/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"code.gitea.io/gitea/models/db"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
Expand All @@ -27,10 +26,6 @@ import (
shared_user "code.gitea.io/gitea/routers/web/shared/user"
)

const (
tplProfileBigAvatar base.TplName = "shared/user/profile_big_avatar"
)

// OwnerProfile render profile page for a user or a organization (aka, repo owner)
func OwnerProfile(ctx *context.Context) {
if strings.Contains(ctx.Req.Header.Get("Accept"), "application/rss+xml") {
Expand Down Expand Up @@ -314,10 +309,8 @@ func Action(ctx *context.Context) {

if err != nil {
log.Error("Failed to apply action %q: %v", ctx.FormString("action"), err)
ctx.Error(http.StatusBadRequest, fmt.Sprintf("Action %q failed", ctx.FormString("action")))
ctx.JSONError(fmt.Sprintf("Action %q failed", ctx.FormString("action")))
return
}

shared_user.PrepareContextForProfileBigAvatar(ctx)
ctx.HTML(http.StatusOK, tplProfileBigAvatar)
ctx.JSONOK()
}
8 changes: 4 additions & 4 deletions templates/shared/user/profile_big_avatar.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div id="profile-avatar-card" class="ui card">
<div class="ui card">
<div id="profile-avatar" class="content gt-df">
{{if eq .SignedUserID .ContextUser.ID}}
<a class="image" href="{{AppSubUrl}}/user/settings" data-tooltip-content="{{ctx.Locale.Tr "user.change_avatar"}}">
Expand Down Expand Up @@ -110,13 +110,13 @@
</li>
{{end}}
{{if and .IsSigned (ne .SignedUserID .ContextUser.ID)}}
<li class="follow" hx-headers='{"x-csrf-token": "{{.CsrfToken}}"}' hx-target="#profile-avatar-card" hx-swap="outerHTML">
<li class="follow">
{{if $.IsFollowing}}
<button hx-post="{{.ContextUser.HomeLink}}?action=unfollow" class="ui basic red button">
<button class="ui basic red button link-action" data-url="{{.ContextUser.HomeLink}}?action=unfollow">
{{svg "octicon-person"}} {{ctx.Locale.Tr "user.unfollow"}}
</button>
{{else}}
<button hx-post="{{.ContextUser.HomeLink}}?action=follow" class="ui basic primary button">
<button class="ui basic primary button link-action" data-url="{{.ContextUser.HomeLink}}?action=follow">
{{svg "octicon-person"}} {{ctx.Locale.Tr "user.follow"}}
</button>
{{end}}
Expand Down

0 comments on commit 0a201f4

Please sign in to comment.