Node.js based forum software built for the modern web
fix pageCount calculation
Barış Soner Uşaklı813fdaf6f6b8
diff --git a/public/src/client/topic/posts.js b/public/src/client/topic/posts.jsindex 626fcde6bd..b44d571919 100644--- a/public/src/client/topic/posts.js+++ b/public/src/client/topic/posts.js@@ -68,7 +68,7 @@ define('forum/topic/posts', [var posts = data.posts;- ajaxify.data.pagination.pageCount = Math.max(1, Math.ceil((posts[0].topic.postcount - 1) / config.postsPerPage));+ ajaxify.data.pagination.pageCount = Math.max(1, Math.ceil(posts[0].topic.postcount / config.postsPerPage));var direction = config.topicPostSort === 'oldest_to_newest' || config.topicPostSort === 'most_votes' ? 1 : -1;var isPostVisible = (ajaxify.data.pagination.currentPage === ajaxify.data.pagination.pageCount && direction === 1) ||diff --git a/src/controllers/topics.js b/src/controllers/topics.jsindex 13228f5779..1936c99481 100644--- a/src/controllers/topics.js+++ b/src/controllers/topics.js@@ -387,7 +387,7 @@ topicsController.pagination = function (req, res, callback) {}var postCount = parseInt(results.topic.postcount, 10);- var pageCount = Math.max(1, Math.ceil((postCount - 1) / results.settings.postsPerPage));+ var pageCount = Math.max(1, Math.ceil(postCount / results.settings.postsPerPage));var paginationData = pagination.create(currentPage, pageCount);paginationData.rel.forEach(function (rel) {diff --git a/src/topics.js b/src/topics.jsindex f20c069d98..2ac14e4264 100644--- a/src/topics.js+++ b/src/topics.js@@ -52,7 +52,7 @@ Topics.getPageCount = function (tid, uid, callback) {user.getSettings(uid, next);},function (settings, next) {- next(null, Math.ceil((parseInt(postCount, 10) - 1) / settings.postsPerPage));+ next(null, Math.ceil(parseInt(postCount, 10) / settings.postsPerPage));},], callback);};