-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't do a full page load when clicking Watch
or Star
#29001
Don't do a full page load when clicking Watch
or Star
#29001
Conversation
- The watch/unwatch button and star/unstar get their own template - The backend returns HTML instead of redirect Signed-off-by: Yarden Shoham <[email protected]>
routers/web/repo/repo.go
Outdated
switch ctx.Params(":action") { | ||
case "watch", "unwatch": | ||
ctx.Data["IsWatchingRepo"] = repo_model.IsWatching(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID) | ||
case "star", "unstar": | ||
ctx.Data["IsStaringRepo"] = repo_model.IsStaring(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID) | ||
} | ||
|
||
switch ctx.Params(":action") { | ||
case "watch", "unwatch", "star", "unstar": | ||
ctx.Data["Repository"], err = repo_model.GetRepositoryByName(ctx, ctx.Repo.Repository.OwnerID, ctx.Repo.Repository.Name) | ||
if err != nil { | ||
ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.Params(":action")), err) | ||
return | ||
} | ||
} | ||
|
||
switch ctx.Params(":action") { | ||
case "watch", "unwatch": | ||
ctx.HTML(http.StatusOK, tplWatchUnwatch) | ||
return | ||
case "star", "unstar": | ||
ctx.HTML(http.StatusOK, tplStarUnstar) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt it makes a significant difference, but can we extract ctx.Params(":action")
to a variable and use that instead of four lookups?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you suggest code? I am not sure how exactly you want it
Co-authored-by: John Olheiser <[email protected]>
This reverts commit 2c5aaa5. It broke the initial page load
@jolheiser I had to revert because the RepoAssignment middleware writes to |
Signed-off-by: Yarden Shoham <[email protected]>
Signed-off-by: Yarden Shoham <[email protected]>
* giteaofficial/main: Hide code links on release page if user cannot read code (go-gitea#29064) [skip ci] Updated translations via Crowdin Don't do a full page load when clicking `Watch` or `Star` (go-gitea#29001) Remove useless template file (go-gitea#29053) Fix typos in the documentation (go-gitea#29048) Move some repository transfer functions to service layer (go-gitea#28855) Propagate install_if and provider_priority to APKINDEX (go-gitea#28899)
…9001) - The watch/unwatch button and star/unstar get their own template - The backend returns HTML instead of redirect --------- Signed-off-by: Yarden Shoham <[email protected]> Co-authored-by: John Olheiser <[email protected]>
Before
After