fix: dont overwrite postIndex

if its not on the current page
isekai-main
Barış Soner Uşaklı 2 years ago
parent cbd98c1b28
commit c21d7dbc7e

@ -76,7 +76,11 @@ topicsController.get = async function getTopic(req, res, next) {
if (!req.query.page) {
currentPage = calculatePageFromIndex(postIndex, settings);
} else {
postIndex = ((currentPage - 1) * settings.postsPerPage) + 1;
const top = ((currentPage - 1) * settings.postsPerPage) + 1;
const bottom = top + settings.postsPerPage;
if (!req.params.post_index || (postIndex < top || postIndex > bottom)) {
postIndex = top;
}
}
}
const { start, stop } = calculateStartStop(currentPage, postIndex, settings);

Loading…
Cancel
Save