mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 11:52:10 +00:00
Don't do a full page load when clicking the subscribe button (#28871)
- Refactor the form around the subscribe button into its own template - Use htmx to perform the form submission - `hx-boost="true"` to prevent the default form submission behavior of a full page load - `hx-sync="this:replace"` to replace the current request (in case the button is clicked again before the response is returned) - `hx-target="this"` to replace the form tag with the new form tag - `hx-push-url="false"` to disable a change to the URL - `hx-swap="show:no-scroll"` to preserve the scroll position - Change the backend response to return a `<form>` tag instead of a redirect to the issue page - Include `htmx.org` in javascript imports This change introduces htmx with the hope we could use it to make Gitea more reactive while keeping our "HTML rendered on the server" approach. # Before  # After  --------- Signed-off-by: Yarden Shoham <git@yardenshoham.com>
This commit is contained in:
parent
80d48621cd
commit
14f6fcf448
7 changed files with 31 additions and 14 deletions
|
@ -8,10 +8,15 @@ import (
|
|||
"strconv"
|
||||
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
)
|
||||
|
||||
const (
|
||||
tplWatching base.TplName = "repo/issue/view_content/watching"
|
||||
)
|
||||
|
||||
// IssueWatch sets issue watching
|
||||
func IssueWatch(ctx *context.Context) {
|
||||
issue := GetActionIssue(ctx)
|
||||
|
@ -52,5 +57,7 @@ func IssueWatch(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.Redirect(issue.Link())
|
||||
ctx.Data["Issue"] = issue
|
||||
ctx.Data["IssueWatch"] = &issues_model.IssueWatch{IsWatching: watch}
|
||||
ctx.HTML(http.StatusOK, tplWatching)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue