mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
@@ -66,7 +66,7 @@ topicsController.get = function (req, res, callback) {
|
||||
|
||||
settings = results.settings;
|
||||
var postCount = parseInt(results.topic.postcount, 10);
|
||||
pageCount = Math.max(1, Math.ceil((postCount - 1) / settings.postsPerPage));
|
||||
pageCount = Math.max(1, Math.ceil(postCount / settings.postsPerPage));
|
||||
|
||||
if (utils.isNumber(req.params.post_index) && (req.params.post_index < 1 || req.params.post_index > postCount)) {
|
||||
return helpers.redirect(res, '/topic/' + req.params.topic_id + '/' + req.params.slug + (req.params.post_index > postCount ? '/' + postCount : ''));
|
||||
|
||||
@@ -234,6 +234,10 @@ var social = require('./social');
|
||||
function getMainPostAndReplies(topic, set, uid, start, stop, reverse, callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
if (start > 0 && stop > 0) {
|
||||
start--;
|
||||
stop--;
|
||||
}
|
||||
posts.getPidsFromSet(set, start, stop, reverse, next);
|
||||
},
|
||||
function (pids, next) {
|
||||
@@ -243,6 +247,7 @@ var social = require('./social');
|
||||
|
||||
if (topic.mainPid && start === 0) {
|
||||
pids.unshift(topic.mainPid);
|
||||
pids.pop();
|
||||
}
|
||||
posts.getPostsByPids(pids, uid, next);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user