mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
fix index to post if sorting is by votes and pagination is used
This commit is contained in:
@@ -89,17 +89,23 @@ topicsController.get = function(req, res, next) {
|
|||||||
var postIndex = 0;
|
var postIndex = 0;
|
||||||
page = parseInt(req.query.page, 10) || 1;
|
page = parseInt(req.query.page, 10) || 1;
|
||||||
req.params.post_index = parseInt(req.params.post_index, 10) || 0;
|
req.params.post_index = parseInt(req.params.post_index, 10) || 0;
|
||||||
|
if (reverse && req.params.post_index === 1) {
|
||||||
|
req.params.post_index = 0;
|
||||||
|
}
|
||||||
if (!settings.usePagination) {
|
if (!settings.usePagination) {
|
||||||
if (reverse) {
|
if (reverse) {
|
||||||
if (req.params.post_index === 1) {
|
postIndex = Math.max(0, postCount - (req.params.post_index || postCount) - (settings.postsPerPage - 1));
|
||||||
req.params.post_index = 0;
|
|
||||||
}
|
|
||||||
postIndex = Math.max(postCount - (req.params.post_index || postCount) - (settings.postsPerPage - 1), 0);
|
|
||||||
} else {
|
} else {
|
||||||
postIndex = Math.max((req.params.post_index || 1) - (settings.postsPerPage + 1), 0);
|
postIndex = Math.max(0, (req.params.post_index || 1) - (settings.postsPerPage + 1));
|
||||||
}
|
}
|
||||||
} else if (!req.query.page) {
|
} else if (!req.query.page) {
|
||||||
var index = Math.max(req.params.post_index - 1, 0) || 0;
|
var index = 0;
|
||||||
|
if (reverse) {
|
||||||
|
index = Math.max(0, postCount - (req.params.post_index || postCount));
|
||||||
|
} else {
|
||||||
|
index = Math.max(0, req.params.post_index - 1) || 0;
|
||||||
|
}
|
||||||
|
|
||||||
page = Math.max(1, Math.ceil(index / settings.postsPerPage));
|
page = Math.max(1, Math.ceil(index / settings.postsPerPage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user