From e291a60964bcbafb170c1378763aa65b9f0b8634 Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Fri, 30 Aug 2019 12:32:21 -0400 Subject: [PATCH] fix: page count for filters --- src/controllers/category.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/category.js b/src/controllers/category.js index b4a39b46d3..65eb23fb62 100644 --- a/src/controllers/category.js +++ b/src/controllers/category.js @@ -47,7 +47,7 @@ categoryController.get = async function (req, res, next) { if (topicIndex < 0 || topicIndex > Math.max(topicCount - 1, 0)) { return helpers.redirect(res, '/category/' + cid + '/' + req.params.slug + (topicIndex > topicCount ? '/' + topicCount : '')); } - const pageCount = Math.max(1, Math.ceil(topicCount / userSettings.topicsPerPage)); + let pageCount = Math.max(1, Math.ceil(topicCount / userSettings.topicsPerPage)); let currentPage = parseInt(req.query.page, 10) || 1; if (userSettings.usePagination && (currentPage < 1 || currentPage > pageCount)) { return next(); @@ -105,7 +105,7 @@ categoryController.get = async function (req, res, next) { categoryData['feeds:disableRSS'] = meta.config['feeds:disableRSS']; categoryData['reputation:disabled'] = meta.config['reputation:disabled']; - + pageCount = Math.max(1, Math.ceil(categoryData.topic_count / userSettings.topicsPerPage)); categoryData.pagination = pagination.create(currentPage, pageCount, req.query); categoryData.pagination.rel.forEach(function (rel) { rel.href = nconf.get('url') + '/category/' + categoryData.slug + rel.href;