Skip to content

Commit 9904d72

Browse files
authored
Merge branch 'main' into minioIamDiscoverySupport
2 parents 7a5d787 + f2a9951 commit 9904d72

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

routers/web/repo/repo.go

+3
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,9 @@ func Action(ctx *context.Context) {
352352
ctx.Data["IsStaringRepo"] = repo_model.IsStaring(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID)
353353
}
354354

355+
// see the `hx-trigger="refreshUserCards ..."` comments in tmpl
356+
ctx.RespHeader().Add("hx-trigger", "refreshUserCards")
357+
355358
switch ctx.PathParam(":action") {
356359
case "watch", "unwatch", "star", "unstar":
357360
// we have to reload the repository because NumStars or NumWatching (used in the templates) has just changed

routers/web/repo/view.go

-3
Original file line numberDiff line numberDiff line change
@@ -1123,8 +1123,6 @@ func RenderUserCards(ctx *context.Context, total int, getter func(opts db.ListOp
11231123
func Watchers(ctx *context.Context) {
11241124
ctx.Data["Title"] = ctx.Tr("repo.watchers")
11251125
ctx.Data["CardsTitle"] = ctx.Tr("repo.watchers")
1126-
ctx.Data["PageIsWatchers"] = true
1127-
11281126
RenderUserCards(ctx, ctx.Repo.Repository.NumWatches, func(opts db.ListOptions) ([]*user_model.User, error) {
11291127
return repo_model.GetRepoWatchers(ctx, ctx.Repo.Repository.ID, opts)
11301128
}, tplWatchers)
@@ -1134,7 +1132,6 @@ func Watchers(ctx *context.Context) {
11341132
func Stars(ctx *context.Context) {
11351133
ctx.Data["Title"] = ctx.Tr("repo.stargazers")
11361134
ctx.Data["CardsTitle"] = ctx.Tr("repo.stargazers")
1137-
ctx.Data["PageIsStargazers"] = true
11381135
RenderUserCards(ctx, ctx.Repo.Repository.NumStars, func(opts db.ListOptions) ([]*user_model.User, error) {
11391136
return repo_model.GetStargazers(ctx, ctx.Repo.Repository, opts)
11401137
}, tplWatchers)

templates/repo/user_cards.tmpl

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
<div class="user-cards">
1+
<!-- Refresh the content if a htmx response contains "HX-Trigger" header.
2+
This usually happens when a user stays on the watchers/stargazers page
3+
when they watched/unwatched/starred/unstarred and the list should be refreshed.
4+
To test go to the watchers page and click the watch button. The user cards should reload.
5+
At the moment, no JS initialization would re-trigger (fortunately there is no JS for this page).
6+
-->
7+
<div class="no-loading-indicator tw-hidden"></div>
8+
<div class="user-cards"
9+
hx-trigger="refreshUserCards from:body" hx-indicator=".no-loading-indicator"
10+
hx-get="{{$.CurrentURL}}" hx-swap="outerHTML" hx-select=".user-cards"
11+
>
212
{{if .CardsTitle}}
313
<h2 class="ui dividing header">
414
{{.CardsTitle}}

0 commit comments

Comments
 (0)