pass on mainPid

v1.18.x
barisusakli 10 years ago
parent c859586269
commit 9062a8f02b

@ -216,7 +216,7 @@ var async = require('async'),
async.parallel({
mainPost: function(next) {
Topics.getMainPost(tid, uid, next);
getMainPosts([topicData.mainPid], uid, next);
},
posts: function(next) {
Topics.getTopicPosts(tid, set, start, end, uid, reverse, next);
@ -230,7 +230,7 @@ var async = require('async'),
return callback(err);
}
topicData.posts = results.mainPost ? [results.mainPost].concat(results.posts) : results.posts;
topicData.posts = Array.isArray(results.mainPost) && results.mainPost.length ? [results.mainPost[0]].concat(results.posts) : results.posts;
topicData.category = results.category;
topicData.thread_tools = results.threadTools;
topicData.tags = results.tags;
@ -262,19 +262,23 @@ var async = require('async'),
return topic ? topic.mainPid : null;
});
posts.getPostsByPids(mainPids, uid, function(err, postData) {
if (err) {
return callback(err);
getMainPosts(mainPids, uid, callback);
});
};
function getMainPosts(mainPids, uid, callback) {
posts.getPostsByPids(mainPids, uid, function(err, postData) {
if (err) {
return callback(err);
}
postData.forEach(function(post) {
if (post) {
post.index = 0;
}
postData.forEach(function(post) {
if (post) {
post.index = 0;
}
});
Topics.addPostData(postData, uid, callback);
});
Topics.addPostData(postData, uid, callback);
});
};
}
Topics.getTopicField = function(tid, field, callback) {
db.getObjectField('topic:' + tid, field, callback);

Loading…
Cancel
Save