fix first post loading when pagination is enabled

v1.18.x
barisusakli 10 years ago
parent cfcfc8e0b1
commit 6a837632fa

@ -14,11 +14,11 @@ define('forum/topic/posts', [
Posts.onNewPost = function(data) {
var tid = ajaxify.variables.get('topic_id');
if(data && data.posts && data.posts.length && parseInt(data.posts[0].tid, 10) !== parseInt(tid, 10)) {
if (data && data.posts && data.posts.length && parseInt(data.posts[0].tid, 10) !== parseInt(tid, 10)) {
return;
}
if(config.usePagination) {
if (config.usePagination) {
return onNewPostPagination(data);
}
@ -32,14 +32,11 @@ define('forum/topic/posts', [
function onNewPostPagination(data) {
var posts = data.posts;
socket.emit('topics.getPageCount', ajaxify.variables.get('topic_id'), function(err, newPageCount) {
if (pagination.currentPage === pagination.pageCount) {
createNewPosts(data);
} else if(data.posts && data.posts.length && parseInt(data.posts[0].uid, 10) === parseInt(app.uid, 10)) {
pagination.loadPage(pagination.pageCount);
}
});
if (pagination.currentPage === pagination.pageCount) {
createNewPosts(data);
} else if(data.posts && data.posts.length && parseInt(data.posts[0].uid, 10) === parseInt(app.uid, 10)) {
pagination.loadPage(pagination.pageCount);
}
}
function createNewPosts(data, callback) {

@ -54,7 +54,7 @@ topicsController.get = function(req, res, next) {
var settings = results.settings;
var postCount = parseInt(results.topic.postcount, 10);
var pageCount = Math.ceil((postCount - 1) / settings.postsPerPage);
var pageCount = Math.max(1, Math.ceil((postCount - 1) / settings.postsPerPage));
if (utils.isNumber(req.params.post_index)) {
var url = '';

Loading…
Cancel
Save