fix empty pages

v1.18.x
barisusakli 11 years ago
parent b12476c422
commit c5ba327d8f

@ -292,7 +292,7 @@ define('forum/topic', dependencies, function(pagination, infinitescroll, threadT
function findInsertionPoint() {
var firstPostTimestamp = parseInt(data.posts[0].timestamp, 10);
var firstPostVotes = parseInt(data.posts[0].votes, 10);
var firstPostPid = data.posts[0].pid;
var firstPostPid = parseInt(data.posts[0].pid, 10);
var firstReply = $('#post-container li.post-row[data-index!="0"]').first();
var lastReply = $('#post-container li.post-row[data-index!="0"]').last();
@ -315,9 +315,9 @@ define('forum/topic', dependencies, function(pagination, infinitescroll, threadT
} else if(firstPostVotes < parseInt(firstReply.attr('data-votes'), 10)) {
after = lastReply;
} else {
if (firstPostPid > firstReply.attr('data-pid')) {
if (firstPostPid <= parseInt(firstReply.attr('data-pid'), 10)) {
before = firstReply;
} else if(firstPostPid <= firstReply.attr('data-pid')) {
} else if(firstPostPid > parseInt(firstReply.attr('data-pid'), 10)) {
after = lastReply;
}
}

@ -44,7 +44,7 @@ topicsController.get = function(req, res, next) {
},
function (results, next) {
var postCount = parseInt(results.postCount, 10) + 1;
var postCount = parseInt(results.postCount, 10);
if (utils.isNumber(req.params.post_index)) {
var url = '';
if (req.params.post_index > postCount) {

@ -428,15 +428,13 @@ SocketTopics.loadMore = function(socket, data, callback) {
reverse = false,
start = Math.max(parseInt(data.after, 10) - 1, 0);
if (results.settings.topicPostSort === 'newest_to_oldest') {
if (results.settings.topicPostSort === 'newest_to_oldest' || results.settings.topicPostSort === 'most_votes') {
reverse = true;
data.after = results.postCount - data.after;
data.after = results.postCount - 1 - data.after;
start = Math.max(parseInt(data.after, 10), 0);
} else if (results.settings.topicPostSort === 'most_votes') {
reverse = true;
data.after = results.postCount - data.after;
start = Math.max(parseInt(data.after, 10), 0);
set = 'tid:' + data.tid + ':posts:votes';
if (results.settings.topicPostSort === 'most_votes') {
set = 'tid:' + data.tid + ':posts:votes';
}
}
var end = start + results.settings.postsPerPage - 1;

Loading…
Cancel
Save