Refactor "htmx" to "fetch action" (#37208)

The only remaining (hard) part is "templates/repo/editor/edit.tmpl", see the FIXME

By the way:

* Make "user unfollow" use basic color but not red color, indeed it is not dangerous
* Fix "org folllow" layout (use block gap instead of inline gap)
This commit is contained in:
wxiaoguang
2026-04-15 02:38:07 +08:00
committed by GitHub
parent 893df6b265
commit 17f62bfec5
10 changed files with 30 additions and 36 deletions
+11 -8
View File
@@ -115,16 +115,19 @@
{{end}}
{{if and .IsSigned (ne .SignedUserID .ContextUser.ID)}}
{{if not .UserBlocking}}
<li class="follow" hx-target="#profile-avatar-card" hx-indicator="#profile-avatar-card">
{{if $.IsFollowing}}
<button hx-post="{{.ContextUser.HomeLink}}?action=unfollow" class="ui basic red button">
<li class="follow">
{{$buttonExtraClass := Iif $.IsFollowing "" "primary"}}
{{$followAction := Iif $.IsFollowing "unfollow" "follow"}}
<button class="ui basic {{$buttonExtraClass}} button"
data-fetch-method="post" data-fetch-url="{{.ContextUser.HomeLink}}?action={{$followAction}}"
data-fetch-sync="$body #profile-avatar-card"
>
{{if $.IsFollowing}}
{{svg "octicon-person"}} {{ctx.Locale.Tr "user.unfollow"}}
</button>
{{else}}
<button hx-post="{{.ContextUser.HomeLink}}?action=follow" class="ui basic primary button">
{{else}}
{{svg "octicon-person"}} {{ctx.Locale.Tr "user.follow"}}
</button>
{{end}}
{{end}}
</button>
</li>
{{end}}
<li>