From 1d4efaee68e75dce75e2d207a27474a86f206ac4 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 6 Jul 2015 13:01:26 -0400 Subject: [PATCH] fix indices if postsPerPage is an odd number --- src/controllers/topics.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/topics.js b/src/controllers/topics.js index b65b3b997a..2975c73cb3 100644 --- a/src/controllers/topics.js +++ b/src/controllers/topics.js @@ -89,9 +89,9 @@ topicsController.get = function(req, res, next) { } if (!settings.usePagination) { if (reverse) { - postIndex = Math.max(0, postCount - (req.params.post_index || postCount) - (settings.postsPerPage / 2)); + postIndex = Math.max(0, postCount - (req.params.post_index || postCount) - Math.ceil(settings.postsPerPage / 2)); } else { - postIndex = Math.max(0, (req.params.post_index || 1) - (settings.postsPerPage / 2)); + postIndex = Math.max(0, (req.params.post_index || 1) - Math.ceil(settings.postsPerPage / 2)); } } else if (!req.query.page) { var index = 0;