mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 22:15:48 +01:00
fix indices, main post always 0
This commit is contained in:
@@ -260,12 +260,20 @@ var async = require('async'),
|
||||
posts.getPostsByPids(pids, uid, 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);
|
||||
posts.forEach(function(post, index) {
|
||||
if (post) {
|
||||
post.index = indices[index] - 1;
|
||||
for (var i=1; i<posts.length; ++i) {
|
||||
if (posts[i]) {
|
||||
posts[i].index = indices[i - 1];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Topics.addPostData(posts, uid, callback);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user