@@ -18,11 +18,11 @@ import (
18
18
type CodeComments map [string ]map [int64 ][]* Comment
19
19
20
20
// FetchCodeComments will return a 2d-map: ["Path"]["Line"] = Comments at line
21
- func FetchCodeComments (ctx context.Context , issue * Issue , currentUser * user_model.User ) (CodeComments , error ) {
22
- return fetchCodeCommentsByReview (ctx , issue , currentUser , nil )
21
+ func FetchCodeComments (ctx context.Context , issue * Issue , currentUser * user_model.User , showOutdatedComments bool ) (CodeComments , error ) {
22
+ return fetchCodeCommentsByReview (ctx , issue , currentUser , nil , showOutdatedComments )
23
23
}
24
24
25
- func fetchCodeCommentsByReview (ctx context.Context , issue * Issue , currentUser * user_model.User , review * Review ) (CodeComments , error ) {
25
+ func fetchCodeCommentsByReview (ctx context.Context , issue * Issue , currentUser * user_model.User , review * Review , showOutdatedComments bool ) (CodeComments , error ) {
26
26
pathToLineToComment := make (CodeComments )
27
27
if review == nil {
28
28
review = & Review {ID : 0 }
@@ -33,7 +33,7 @@ func fetchCodeCommentsByReview(ctx context.Context, issue *Issue, currentUser *u
33
33
ReviewID : review .ID ,
34
34
}
35
35
36
- comments , err := findCodeComments (ctx , opts , issue , currentUser , review )
36
+ comments , err := findCodeComments (ctx , opts , issue , currentUser , review , showOutdatedComments )
37
37
if err != nil {
38
38
return nil , err
39
39
}
@@ -47,15 +47,17 @@ func fetchCodeCommentsByReview(ctx context.Context, issue *Issue, currentUser *u
47
47
return pathToLineToComment , nil
48
48
}
49
49
50
- func findCodeComments (ctx context.Context , opts FindCommentsOptions , issue * Issue , currentUser * user_model.User , review * Review ) ([]* Comment , error ) {
50
+ func findCodeComments (ctx context.Context , opts FindCommentsOptions , issue * Issue , currentUser * user_model.User , review * Review , showOutdatedComments bool ) ([]* Comment , error ) {
51
51
var comments CommentList
52
52
if review == nil {
53
53
review = & Review {ID : 0 }
54
54
}
55
55
conds := opts .ToConds ()
56
- if review .ID == 0 {
56
+
57
+ if ! showOutdatedComments && review .ID == 0 {
57
58
conds = conds .And (builder.Eq {"invalidated" : false })
58
59
}
60
+
59
61
e := db .GetEngine (ctx )
60
62
if err := e .Where (conds ).
61
63
Asc ("comment.created_unix" ).
@@ -118,12 +120,12 @@ func findCodeComments(ctx context.Context, opts FindCommentsOptions, issue *Issu
118
120
}
119
121
120
122
// FetchCodeCommentsByLine fetches the code comments for a given treePath and line number
121
- func FetchCodeCommentsByLine (ctx context.Context , issue * Issue , currentUser * user_model.User , treePath string , line int64 ) ([]* Comment , error ) {
123
+ func FetchCodeCommentsByLine (ctx context.Context , issue * Issue , currentUser * user_model.User , treePath string , line int64 , showOutdatedComments bool ) ([]* Comment , error ) {
122
124
opts := FindCommentsOptions {
123
125
Type : CommentTypeCode ,
124
126
IssueID : issue .ID ,
125
127
TreePath : treePath ,
126
128
Line : line ,
127
129
}
128
- return findCodeComments (ctx , opts , issue , currentUser , nil )
130
+ return findCodeComments (ctx , opts , issue , currentUser , nil , showOutdatedComments )
129
131
}
0 commit comments