aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorYarden Shoham <git@yardenshoham.com>2024-11-22 20:51:51 +0200
committerGitHub <noreply@github.com>2024-11-22 18:51:51 +0000
commitf2a995174101b9fa9409acb2b47b065262098b28 (patch)
treed1810343bd313c00f74eeb5aa38ff7daac4c7996 /routers
parentae90b21db036507b8df9ed22e7ba416139037547 (diff)
downloadgitea-f2a995174101b9fa9409acb2b47b065262098b28.tar.gz
gitea-f2a995174101b9fa9409acb2b47b065262098b28.zip
Update the list of watchers and stargazers when clicking watch/unwatch or star/unstar (#32570)
We make sure the user cards are updated - Fixes https://github.com/go-gitea/gitea/issues/32561 I also removed `ctx.Data["PageIsWatchers"] = true` and `ctx.Data["PageIsStargazers"] = true` as they are not used anywhere. # Before ![before](https://github.com/user-attachments/assets/e3bc3235-35eb-4eda-862d-bdf2510282ea) # After ![after](https://github.com/user-attachments/assets/bc0488a5-8399-4cf6-95c9-17328a9702eb) --------- Signed-off-by: Yarden Shoham <git@yardenshoham.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: silverwind <me@silverwind.io>
Diffstat (limited to 'routers')
-rw-r--r--routers/web/repo/repo.go3
-rw-r--r--routers/web/repo/view.go3
2 files changed, 3 insertions, 3 deletions
diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go
index be6f2d483f..b62fd21585 100644
--- a/routers/web/repo/repo.go
+++ b/routers/web/repo/repo.go
@@ -352,6 +352,9 @@ func Action(ctx *context.Context) {
ctx.Data["IsStaringRepo"] = repo_model.IsStaring(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID)
}
+ // see the `hx-trigger="refreshUserCards ..."` comments in tmpl
+ ctx.RespHeader().Add("hx-trigger", "refreshUserCards")
+
switch ctx.PathParam(":action") {
case "watch", "unwatch", "star", "unstar":
// we have to reload the repository because NumStars or NumWatching (used in the templates) has just changed
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go
index aacd7de6b1..ec2ddfd79f 100644
--- a/routers/web/repo/view.go
+++ b/routers/web/repo/view.go
@@ -1123,8 +1123,6 @@ func RenderUserCards(ctx *context.Context, total int, getter func(opts db.ListOp
func Watchers(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.watchers")
ctx.Data["CardsTitle"] = ctx.Tr("repo.watchers")
- ctx.Data["PageIsWatchers"] = true
-
RenderUserCards(ctx, ctx.Repo.Repository.NumWatches, func(opts db.ListOptions) ([]*user_model.User, error) {
return repo_model.GetRepoWatchers(ctx, ctx.Repo.Repository.ID, opts)
}, tplWatchers)
@@ -1134,7 +1132,6 @@ func Watchers(ctx *context.Context) {
func Stars(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.stargazers")
ctx.Data["CardsTitle"] = ctx.Tr("repo.stargazers")
- ctx.Data["PageIsStargazers"] = true
RenderUserCards(ctx, ctx.Repo.Repository.NumStars, func(opts db.ListOptions) ([]*user_model.User, error) {
return repo_model.GetStargazers(ctx, ctx.Repo.Repository, opts)
}, tplWatchers)