Skip to content

Commit d79bfb4

Browse files
committed
follow @delvh suggestion
1 parent 5fca5c1 commit d79bfb4

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

models/activities/action.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,19 @@ func (a *Action) GetCommentHTMLURL() string {
228228
return a.getCommentHTMLURL(db.DefaultContext)
229229
}
230230

231+
func (a *Action) loadComment(ctx context.Context) (err error) {
232+
if a.CommentID == 0 || a.Comment != nil {
233+
return nil
234+
}
235+
a.Comment, err = issues_model.GetCommentByID(ctx, a.CommentID)
236+
return
237+
}
238+
231239
func (a *Action) getCommentHTMLURL(ctx context.Context) string {
232240
if a == nil {
233241
return "#"
234242
}
235-
if a.Comment == nil && a.CommentID != 0 {
236-
a.Comment, _ = issues_model.GetCommentByID(ctx, a.CommentID)
237-
}
243+
_ = a.loadComment(ctx)
238244
if a.Comment != nil {
239245
return a.Comment.HTMLURL()
240246
}
@@ -269,9 +275,7 @@ func (a *Action) getCommentLink(ctx context.Context) string {
269275
if a == nil {
270276
return "#"
271277
}
272-
if a.Comment == nil && a.CommentID != 0 {
273-
a.Comment, _ = issues_model.GetCommentByID(ctx, a.CommentID)
274-
}
278+
_ = a.loadComment(ctx)
275279
if a.Comment != nil {
276280
return a.Comment.Link()
277281
}

0 commit comments

Comments
 (0)