mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-22 01:34:18 +00:00
Fix show single review comments in the PR page (#9143)
This commit is contained in:
parent
8ab35eefc4
commit
d779deef6e
2 changed files with 34 additions and 3 deletions
|
@ -19,9 +19,28 @@ import (
|
|||
|
||||
// CreateCodeComment creates a comment on the code line
|
||||
func CreateCodeComment(doer *models.User, issue *models.Issue, line int64, content string, treePath string, isReview bool, replyReviewID int64) (*models.Comment, error) {
|
||||
// It's not a review, maybe a reply to a review comment or a single comment.
|
||||
|
||||
var (
|
||||
existsReview bool
|
||||
err error
|
||||
)
|
||||
|
||||
// CreateCodeComment() is used for:
|
||||
// - Single comments
|
||||
// - Comments that are part of a review
|
||||
// - Comments that reply to an existing review
|
||||
|
||||
if !isReview {
|
||||
if err := issue.LoadRepo(); err != nil {
|
||||
// It's not part of a review; maybe a reply to a review comment or a single comment.
|
||||
// Check if there are reviews for that line already; if there are, this is a reply
|
||||
if existsReview, err = models.ReviewExists(issue, treePath, line); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// Comments that are replies don't require a review header to show up in the issue view
|
||||
if !isReview && existsReview {
|
||||
if err = issue.LoadRepo(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -72,7 +91,14 @@ func CreateCodeComment(doer *models.User, issue *models.Issue, line int64, conte
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// NOTICE: it's a pending review, so the notifications will not be fired until user submit review.
|
||||
if !isReview && !existsReview {
|
||||
// Submit the review we've just created so the comment shows up in the issue view
|
||||
if _, _, err = SubmitReview(doer, issue, models.ReviewTypeComment, ""); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// NOTICE: if it's a pending review the notifications will not be fired until user submit review.
|
||||
|
||||
return comment, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue