Skip to content

Commit 64f6a5d

Browse files
authored
Use CommentList instead of []*Comment (#24828)
As title.
1 parent edd8ea0 commit 64f6a5d

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

models/issues/comment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ func (opts *FindCommentsOptions) ToConds() builder.Cond {
10481048
}
10491049

10501050
// FindComments returns all comments according options
1051-
func FindComments(ctx context.Context, opts *FindCommentsOptions) ([]*Comment, error) {
1051+
func FindComments(ctx context.Context, opts *FindCommentsOptions) (CommentList, error) {
10521052
comments := make([]*Comment, 0, 10)
10531053
sess := db.GetEngine(ctx).Where(opts.ToConds())
10541054
if opts.RepoID > 0 {

models/issues/comment_code.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func fetchCodeCommentsByReview(ctx context.Context, issue *Issue, currentUser *u
4848
}
4949

5050
func findCodeComments(ctx context.Context, opts FindCommentsOptions, issue *Issue, currentUser *user_model.User, review *Review) ([]*Comment, error) {
51-
var comments []*Comment
51+
var comments CommentList
5252
if review == nil {
5353
review = &Review{ID: 0}
5454
}
@@ -68,7 +68,7 @@ func findCodeComments(ctx context.Context, opts FindCommentsOptions, issue *Issu
6868
return nil, err
6969
}
7070

71-
if err := CommentList(comments).LoadPosters(ctx); err != nil {
71+
if err := comments.LoadPosters(ctx); err != nil {
7272
return nil, err
7373
}
7474

models/issues/issue.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ type Issue struct {
124124
ClosedUnix timeutil.TimeStamp `xorm:"INDEX"`
125125

126126
Attachments []*repo_model.Attachment `xorm:"-"`
127-
Comments []*Comment `xorm:"-"`
127+
Comments CommentList `xorm:"-"`
128128
Reactions ReactionList `xorm:"-"`
129129
TotalTrackedTime int64 `xorm:"-"`
130130
Assignees []*user_model.User `xorm:"-"`
@@ -353,7 +353,7 @@ func (issue *Issue) LoadAttributes(ctx context.Context) (err error) {
353353
return err
354354
}
355355

356-
if err = CommentList(issue.Comments).loadAttributes(ctx); err != nil {
356+
if err = issue.Comments.loadAttributes(ctx); err != nil {
357357
return err
358358
}
359359
if issue.IsTimetrackerEnabled(ctx) {

routers/api/v1/repo/issue_comment.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ func ListIssueComments(ctx *context.APIContext) {
9090
return
9191
}
9292

93-
if err := issues_model.CommentList(comments).LoadPosters(ctx); err != nil {
93+
if err := comments.LoadPosters(ctx); err != nil {
9494
ctx.Error(http.StatusInternalServerError, "LoadPosters", err)
9595
return
9696
}
9797

98-
if err := issues_model.CommentList(comments).LoadAttachments(ctx); err != nil {
98+
if err := comments.LoadAttachments(ctx); err != nil {
9999
ctx.Error(http.StatusInternalServerError, "LoadAttachments", err)
100100
return
101101
}
@@ -182,7 +182,7 @@ func ListIssueCommentsAndTimeline(ctx *context.APIContext) {
182182
return
183183
}
184184

185-
if err := issues_model.CommentList(comments).LoadPosters(ctx); err != nil {
185+
if err := comments.LoadPosters(ctx); err != nil {
186186
ctx.Error(http.StatusInternalServerError, "LoadPosters", err)
187187
return
188188
}
@@ -285,25 +285,25 @@ func ListRepoIssueComments(ctx *context.APIContext) {
285285
return
286286
}
287287

288-
if err = issues_model.CommentList(comments).LoadPosters(ctx); err != nil {
288+
if err = comments.LoadPosters(ctx); err != nil {
289289
ctx.Error(http.StatusInternalServerError, "LoadPosters", err)
290290
return
291291
}
292292

293293
apiComments := make([]*api.Comment, len(comments))
294-
if err := issues_model.CommentList(comments).LoadIssues(ctx); err != nil {
294+
if err := comments.LoadIssues(ctx); err != nil {
295295
ctx.Error(http.StatusInternalServerError, "LoadIssues", err)
296296
return
297297
}
298-
if err := issues_model.CommentList(comments).LoadPosters(ctx); err != nil {
298+
if err := comments.LoadPosters(ctx); err != nil {
299299
ctx.Error(http.StatusInternalServerError, "LoadPosters", err)
300300
return
301301
}
302-
if err := issues_model.CommentList(comments).LoadAttachments(ctx); err != nil {
302+
if err := comments.LoadAttachments(ctx); err != nil {
303303
ctx.Error(http.StatusInternalServerError, "LoadAttachments", err)
304304
return
305305
}
306-
if _, err := issues_model.CommentList(comments).Issues().LoadRepositories(ctx); err != nil {
306+
if _, err := comments.Issues().LoadRepositories(ctx); err != nil {
307307
ctx.Error(http.StatusInternalServerError, "LoadRepositories", err)
308308
return
309309
}

0 commit comments

Comments
 (0)