From 813fdaf6f6b8cefa4fd7336d8888af9aefa01905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Tue, 23 Jan 2018 15:52:54 -0500 Subject: [PATCH] fix pageCount calculation --- public/src/client/topic/posts.js | 2 +- src/controllers/topics.js | 2 +- src/topics.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/src/client/topic/posts.js b/public/src/client/topic/posts.js index 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.js index 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.js index 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); };