Skip to content

Commit 210a6ce

Browse files
committed
record comment id instead of index of comment
1 parent 799fb4b commit 210a6ce

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

routers/web/repo/issue.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,11 +1420,12 @@ func ViewIssue(ctx *context.Context) {
14201420
}
14211421

14221422
var (
1423-
role issues_model.RoleDescriptor
1424-
ok bool
1425-
marked = make(map[int64]issues_model.RoleDescriptor)
1426-
participants = make([]*user_model.User, 1, 10)
1427-
latestCloseCommentIndex int
1423+
role issues_model.RoleDescriptor
1424+
ok bool
1425+
marked = make(map[int64]issues_model.RoleDescriptor)
1426+
comment *issues_model.Comment
1427+
participants = make([]*user_model.User, 1, 10)
1428+
latestCloseCommentID int64
14281429
)
14291430
if ctx.Repo.Repository.IsTimetrackerEnabled(ctx) {
14301431
if ctx.IsSigned {
@@ -1468,7 +1469,7 @@ func ViewIssue(ctx *context.Context) {
14681469

14691470
// Render comments and and fetch participants.
14701471
participants[0] = issue.Poster
1471-
for i, comment := range issue.Comments {
1472+
for _, comment = range issue.Comments {
14721473
comment.Issue = issue
14731474

14741475
if err := comment.LoadPoster(ctx); err != nil {
@@ -1623,12 +1624,13 @@ func ViewIssue(ctx *context.Context) {
16231624
// drop error since times could be pruned from DB..
16241625
_ = comment.LoadTime()
16251626
} else if comment.Type == issues_model.CommentTypeClose {
1626-
// record latest index of close comment.
1627-
latestCloseCommentIndex = i
1627+
// record ID of latest closed comment.
1628+
// if PR is closed, the comments after it won't be rendered.
1629+
latestCloseCommentID = comment.ID
16281630
}
16291631
}
16301632

1631-
ctx.Data["LatestCloseCommentIndex"] = latestCloseCommentIndex
1633+
ctx.Data["LatestCloseCommentID"] = latestCloseCommentID
16321634

16331635
// Combine multiple label assignments into a single comment
16341636
combineLabelComments(issue)

templates/repo/issue/view_content/comments.tmpl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{{template "base/alert"}}
2-
<div>
3-
{{range $idx, $comment := .Issue.Comments}}
2+
{{range .Issue.Comments}}
43
{{if call $.ShouldShowCommentType .Type}}
54
{{$createdStr:= TimeSinceUnix .CreatedUnix $.locale}}
65

@@ -118,7 +117,7 @@
118117
{{end}}
119118
</span>
120119
</div>
121-
{{if and .Issue.IsClosed (eq $.LatestCloseCommentIndex $idx)}}
120+
{{if and .Issue.IsClosed (eq $.LatestCloseCommentID .ID)}}
122121
{{break}}
123122
{{end}}
124123
{{else if eq .Type 28}}
@@ -800,4 +799,3 @@
800799
{{end}}
801800
{{end}}
802801
{{end}}
803-
</div>

0 commit comments

Comments
 (0)