diff --git a/public/src/client/recent.js b/public/src/client/recent.js index 22777be4f6..938453894e 100644 --- a/public/src/client/recent.js +++ b/public/src/client/recent.js @@ -1,6 +1,6 @@ 'use strict'; -/* globals define, app, socket, utils */ +/* globals define, app, socket, utils, ajaxify, config */ define('forum/recent', ['forum/infinitescroll', 'components'], function(infinitescroll, components) { var Recent = {}; @@ -55,11 +55,15 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function(infinite Recent.updateAlertText(); } - if (parseInt(data.topic.mainPid, 10) === parseInt(data.posts[0].pid, 10)) { + var post = data.posts[0]; + if (!post || !post.topic) { + return; + } + if (parseInt(post.topic.mainPid, 10) === parseInt(post.pid, 10)) { return; } - if (ajaxify.data.selectedCategory && parseInt(ajaxify.data.selectedCategory.cid, 10) !== parseInt(data.topic.cid, 10)) { + if (ajaxify.data.selectedCategory && parseInt(ajaxify.data.selectedCategory.cid, 10) !== parseInt(post.topic.cid, 10)) { return; } @@ -68,7 +72,7 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function(infinite } if (ajaxify.data.selectedFilter && ajaxify.data.selectedFilter.url === 'unread/watched') { - socket.emit('topics.isFollowed', data.topic.tid, function(err, isFollowed) { + socket.emit('topics.isFollowed', post.tid, function(err, isFollowed) { if (err) { app.alertError(err.message); } diff --git a/src/socket.io/topics/unread.js b/src/socket.io/topics/unread.js index 4a6153b397..a5582d6892 100644 --- a/src/socket.io/topics/unread.js +++ b/src/socket.io/topics/unread.js @@ -46,7 +46,7 @@ module.exports = function(SocketTopics) { }; SocketTopics.markCategoryTopicsRead = function(socket, cid, callback) { - topics.getUnreadTids(cid, socket.uid, function(err, tids) { + topics.getUnreadTids(cid, socket.uid, '', function(err, tids) { if (err) { return callback(err); } diff --git a/src/topics/create.js b/src/topics/create.js index dea303709c..01a8ea5f5f 100644 --- a/src/topics/create.js +++ b/src/topics/create.js @@ -274,7 +274,7 @@ module.exports = function(Topics) { posts.getUserInfoForPosts([postData.uid], uid, next); }, topicInfo: function(next) { - Topics.getTopicFields(tid, ['tid', 'title', 'slug', 'cid', 'postcount'], next); + Topics.getTopicFields(tid, ['tid', 'title', 'slug', 'cid', 'postcount', 'mainPid'], next); }, parents: function(next) { Topics.addParentPosts([postData], next);