fix indices, main post always 0

v1.18.x
barisusakli 10 years ago
parent fd1b7bbd3a
commit 4cb58d976b

@ -260,12 +260,20 @@ var async = require('async'),
posts.getPostsByPids(pids, uid, next); posts.getPostsByPids(pids, uid, next);
}, },
function(posts, next) { function(posts, next) {
if (!posts.length) {
return next(null, []);
}
if (topic.mainPid) {
posts[0].index = 0;
}
var indices = Topics.calculatePostIndices(start, end, topic.postcount, reverse); var indices = Topics.calculatePostIndices(start, end, topic.postcount, reverse);
posts.forEach(function(post, index) { for (var i=1; i<posts.length; ++i) {
if (post) { if (posts[i]) {
post.index = indices[index] - 1; posts[i].index = indices[i - 1];
} }
}); }
Topics.addPostData(posts, uid, callback); Topics.addPostData(posts, uid, callback);
} }

Loading…
Cancel
Save