mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-04 21:15:55 +01:00
Topic await errors (#7727)
* feat: derp await * feat: restore user.getSettings * feat: cleanup * feat: make tid const * feat: cleanup * fix: tests * feat: deprecate filter:controllers.topic.get * feat: rewrite post-index logic * feat: change calculation to match others * fix: use .async * feat: remove try/catch wrapper
This commit is contained in:
committed by
GitHub
parent
5e46cf9b09
commit
bd640a1107
@@ -27,19 +27,12 @@ module.exports = function (Topics) {
|
||||
Topics.getTopicPosts = function (tid, set, start, stop, uid, reverse, callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
async.parallel({
|
||||
posts: function (next) {
|
||||
posts.getPostsFromSet(set, start, stop, uid, reverse, next);
|
||||
},
|
||||
postCount: function (next) {
|
||||
Topics.getTopicField(tid, 'postcount', next);
|
||||
},
|
||||
}, next);
|
||||
posts.getPostsFromSet(set, start, stop, uid, reverse, next);
|
||||
},
|
||||
function (results, next) {
|
||||
Topics.calculatePostIndices(results.posts, start, results.postCount, reverse);
|
||||
function (posts, next) {
|
||||
Topics.calculatePostIndices(posts, start);
|
||||
|
||||
Topics.addPostData(results.posts, uid, next);
|
||||
Topics.addPostData(posts, uid, next);
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
@@ -185,11 +178,9 @@ module.exports = function (Topics) {
|
||||
], callback);
|
||||
};
|
||||
|
||||
Topics.calculatePostIndices = function (posts, start, postCount, reverse) {
|
||||
Topics.calculatePostIndices = function (posts, start) {
|
||||
posts.forEach(function (post, index) {
|
||||
if (reverse) {
|
||||
post.index = postCount - (start + index + 1);
|
||||
} else {
|
||||
if (post) {
|
||||
post.index = start + index + 1;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user