Skip to content

Node.js based forum software built for the modern web

getMainPost uses getMainPosts

barisusakli22fdf9f4eddd
diff --git a/src/topics.js b/src/topics.js
index a2d3130ae3..596aab1929 100644
--- a/src/topics.js
+++ b/src/topics.js
@@ -308,23 +308,8 @@ var async = require('async'),
};
Topics.getMainPost = function(tid, uid, callback) {
- Topics.getTopicField(tid, 'mainPid', function(err, mainPid) {
- if (err) {
- return callback(err);
- }
- if (!parseInt(mainPid, 10)) {
- return callback(null, []);
- }
- posts.getPostsByPids([mainPid], function(err, postData) {
- if (err) {
- return callback(err);
- }
- if (!Array.isArray(postData) || !postData[0]) {
- return callback(null, []);
- }
- postData[0].index = 0;
- Topics.addPostData(postData, uid, callback);
- });
+ Topics.getMainPosts([tid], uid, function(err, mainPosts) {
+ calllback(err, Array.isArray(mainPosts) && mainPosts.length ? mainPosts[0] : null);
});
};