dont crash if post.user or post.category doesn't exist

v1.18.x
barisusakli 10 years ago
parent 5c0bcd7e5d
commit 832430ed37

@ -99,8 +99,8 @@ function filterPosts(data, searchCategories, posts) {
if (postedBy || searchCategories.length || data.replies) {
posts = posts.filter(function(post) {
return post &&
(postedBy ? (post.user && post.user.username) === postedBy : true) &&
(searchCategories.length ? searchCategories.indexOf(post.category.cid) !== -1 : true) &&
(postedBy ? post.user && (post.user.username === postedBy) : true) &&
(searchCategories.length ? (post.category && searchCategories.indexOf(post.category.cid) !== -1) : true) &&
(data.replies ? (isAtLeast ? post.topic.postcount >= data.replies : post.topic.postcount <= data.replies) : true);
});
}

Loading…
Cancel
Save