Skip to content

Commit e7e5507

Browse files
committed
Merge pull request #566 from Martii/fixNull_discussionIdInUserCommentsList
Work-around for null `_discussionId` in User comment lists Auto-merge
2 parents f8bdadb + 048d408 commit e7e5507

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

controllers/user.js

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -375,25 +375,27 @@ exports.userCommentListPage = function (aReq, aRes, aNext) {
375375

376376
// comment.discussion & comment.category & comment.script
377377
_.map(options.commentList, function (aComment) {
378-
aComment.discussion = modelParser.parseDiscussion(aComment._discussionId);
378+
if (aComment._discussionId) {
379+
aComment.discussion = modelParser.parseDiscussion(aComment._discussionId);
379380

380-
var category = _.findWhere(categories, { slug: aComment.discussion.category });
381-
if (!category) {
382-
category = modelParser.parseCategoryUnknown(aComment.discussion.category);
383-
}
384-
aComment.category = modelParser.parseCategory(category);
385-
386-
if (aComment.discussion.issue) {
387-
aComment.script = {
388-
scriptPageUrl: aComment.category.categoryPageUrl.replace('/issues', ''),
389-
name: category.name
390-
};
391-
category.name = 'Issues';
392-
} else {
393-
aComment.script = {
394-
scriptPageUrl: '/forum',
395-
name: 'Forum'
396-
};
381+
var category = _.findWhere(categories, { slug: aComment.discussion.category });
382+
if (!category) {
383+
category = modelParser.parseCategoryUnknown(aComment.discussion.category);
384+
}
385+
aComment.category = modelParser.parseCategory(category);
386+
387+
if (aComment.discussion.issue) {
388+
aComment.script = {
389+
scriptPageUrl: aComment.category.categoryPageUrl.replace('/issues', ''),
390+
name: category.name
391+
};
392+
category.name = 'Issues';
393+
} else {
394+
aComment.script = {
395+
scriptPageUrl: '/forum',
396+
name: 'Forum'
397+
};
398+
}
397399
}
398400
});
399401

0 commit comments

Comments
 (0)