summaryrefslogtreecommitdiffstats
path: root/routers/web/repo
diff options
context:
space:
mode:
authorJimmy Praet <jimmy.praet@telenet.be>2024-01-24 20:09:48 +0100
committerGitHub <noreply@github.com>2024-01-24 20:09:48 +0100
commit9210ce4045897ebd03a5767b8f7fcf56ff11bf6d (patch)
tree3dd949c13f12d02fa04a61a91ac3c5fe92346259 /routers/web/repo
parentcebf55f6b1af49afa8e41a3c446d6cf07dfb858e (diff)
downloadgitea-9210ce4045897ebd03a5767b8f7fcf56ff11bf6d.tar.gz
gitea-9210ce4045897ebd03a5767b8f7fcf56ff11bf6d.zip
Don't reload timeline page when (un)resolving or replying conversation (#28654) (#28917)
Backport #28654 Fixes #15981
Diffstat (limited to 'routers/web/repo')
-rw-r--r--routers/web/repo/pull_review.go32
1 files changed, 16 insertions, 16 deletions
diff --git a/routers/web/repo/pull_review.go b/routers/web/repo/pull_review.go
index 1359af9d3b..156b70a999 100644
--- a/routers/web/repo/pull_review.go
+++ b/routers/web/repo/pull_review.go
@@ -21,8 +21,9 @@ import (
)
const (
- tplConversation base.TplName = "repo/diff/conversation"
- tplNewComment base.TplName = "repo/diff/new_comment"
+ tplDiffConversation base.TplName = "repo/diff/conversation"
+ tplTimelineConversation base.TplName = "repo/issue/view_content/conversation"
+ tplNewComment base.TplName = "repo/diff/new_comment"
)
// RenderNewCodeCommentForm will render the form for creating a new review comment
@@ -97,11 +98,7 @@ func CreateCodeComment(ctx *context.Context) {
log.Trace("Comment created: %-v #%d[%d] Comment[%d]", ctx.Repo.Repository, issue.Index, issue.ID, comment.ID)
- if form.Origin == "diff" {
- renderConversation(ctx, comment)
- return
- }
- ctx.Redirect(comment.Link(ctx))
+ renderConversation(ctx, comment, form.Origin)
}
// UpdateResolveConversation add or remove an Conversation resolved mark
@@ -152,22 +149,21 @@ func UpdateResolveConversation(ctx *context.Context) {
return
}
- if origin == "diff" {
- renderConversation(ctx, comment)
- return
- }
- ctx.JSONOK()
+ renderConversation(ctx, comment, origin)
}
-func renderConversation(ctx *context.Context, comment *issues_model.Comment) {
+func renderConversation(ctx *context.Context, comment *issues_model.Comment, origin string) {
comments, err := issues_model.FetchCodeCommentsByLine(ctx, comment.Issue, ctx.Doer, comment.TreePath, comment.Line, ctx.Data["ShowOutdatedComments"].(bool))
if err != nil {
ctx.ServerError("FetchCodeCommentsByLine", err)
return
}
- ctx.Data["PageIsPullFiles"] = true
+ ctx.Data["PageIsPullFiles"] = (origin == "diff")
ctx.Data["comments"] = comments
- ctx.Data["CanMarkConversation"] = true
+ if ctx.Data["CanMarkConversation"], err = issues_model.CanMarkConversation(ctx, comment.Issue, ctx.Doer); err != nil {
+ ctx.ServerError("CanMarkConversation", err)
+ return
+ }
ctx.Data["Issue"] = comment.Issue
if err = comment.Issue.LoadPullRequest(ctx); err != nil {
ctx.ServerError("comment.Issue.LoadPullRequest", err)
@@ -179,7 +175,11 @@ func renderConversation(ctx *context.Context, comment *issues_model.Comment) {
return
}
ctx.Data["AfterCommitID"] = pullHeadCommitID
- ctx.HTML(http.StatusOK, tplConversation)
+ if origin == "diff" {
+ ctx.HTML(http.StatusOK, tplDiffConversation)
+ } else if origin == "timeline" {
+ ctx.HTML(http.StatusOK, tplTimelineConversation)
+ }
}
// SubmitReview creates a review out of the existing pending review or creates a new one if no pending review exist