From 94cd7bb25b8f142d2865aaf740ae19cd98ca6927 Mon Sep 17 00:00:00 2001 From: Jonas Franz Date: Fri, 5 Oct 2018 17:49:30 +0200 Subject: [PATCH] Hide outdated comments in file view (#5017) * Hide outdated comments in file view Signed-off-by: Jonas Franz * Add unit test by adding "invalidated" comment to fixtures Signed-off-by: Jonas Franz --- models/fixtures/comment.yml | 11 +++++++++++ models/issue_comment.go | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/models/fixtures/comment.yml b/models/fixtures/comment.yml index 6d4812f096..6abd26973b 100644 --- a/models/fixtures/comment.yml +++ b/models/fixtures/comment.yml @@ -41,3 +41,14 @@ tree_path: "README.md" created_unix: 946684812 invalidated: false + +- + id: 6 + type: 21 # code comment + poster_id: 1 + issue_id: 2 + content: "it's already invalidated. boring..." + line: -4 + tree_path: "README.md" + created_unix: 946684812 + invalidated: true diff --git a/models/issue_comment.go b/models/issue_comment.go index eb185a7662..0085c7a732 100644 --- a/models/issue_comment.go +++ b/models/issue_comment.go @@ -1084,7 +1084,7 @@ func fetchCodeCommentsByReview(e Engine, issue *Issue, currentUser *User, review } conds := opts.toConds() if review.ID == 0 { - conds.And(builder.Eq{"invalidated": false}) + conds = conds.And(builder.Eq{"invalidated": false}) } var comments []*Comment