Added check for map key

pull/24/head
マリウス 3 years ago
parent 2781f76f35
commit ed3078e2d3
No known key found for this signature in database
GPG Key ID: 272ED814BF63261F

@ -249,8 +249,10 @@ func (db *Database) ListArticles() ([]*models.Article, []*models.Article, error)
var articlesRoots []*models.Article
for i := 0; i < len(articles); i++ {
if articles[i].InReplyToID != "" {
(*articlesMap[articles[i].InReplyToID]).Replies =
append((*articlesMap[articles[i].InReplyToID]).Replies, articles[i])
if _, exist := articlesMap[articles[i].InReplyToID]; exist == true {
(*articlesMap[articles[i].InReplyToID]).Replies =
append((*articlesMap[articles[i].InReplyToID]).Replies, articles[i])
}
} else {
articlesRoots = append(articlesRoots, articles[i])
}

Loading…
Cancel
Save