From f505b47ac957a5a5c22c6294ec414dabdfa9d0a0 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Thu, 22 Dec 2016 12:19:07 +0300 Subject: [PATCH] prevent crash if topic is not found --- src/posts/summary.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/posts/summary.js b/src/posts/summary.js index 270d9d480b..2173057e3a 100644 --- a/src/posts/summary.js +++ b/src/posts/summary.js @@ -65,8 +65,8 @@ module.exports = function (Posts) { } post.user = results.users[post.uid]; post.topic = results.topics[post.tid]; - post.category = results.categories[post.topic.cid]; - post.isMainPost = parseInt(post.pid, 10) === parseInt(post.topic.mainPid, 10); + post.category = post.topic && results.categories[post.topic.cid]; + post.isMainPost = post.topic && parseInt(post.pid, 10) === parseInt(post.topic.mainPid, 10); post.deleted = parseInt(post.deleted, 10) === 1; post.upvotes = parseInt(post.upvotes, 10) || 0; post.downvotes = parseInt(post.downvotes, 10) || 0;