fix pageCount calculation

v1.18.x
Barış Soner Uşaklı 7 years ago
parent d70cdf1e28
commit 813fdaf6f6

@ -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) ||

@ -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) {

@ -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);
};

Loading…
Cancel
Save