diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index 74b3c3e6af..57a46b0603 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -957,7 +957,8 @@ define(['composer'], function(composer) { }); setTimeout(function() { - if (scrollTop + windowHeight == jQuery(document).height()) { + console.log(infiniteLoaderActive); + if (scrollTop + windowHeight == jQuery(document).height() && !infiniteLoaderActive) { pagination.innerHTML = Topic.postCount + ' out of ' + Topic.postCount; progressBar.width('100%'); } @@ -1099,32 +1100,35 @@ define(['composer'], function(composer) { return; } - infiniteLoaderActive = true; if (indicatorEl.attr('done') === '0') { + infiniteLoaderActive = true; indicatorEl.fadeIn(); - } - socket.emit('topics.loadMore', { - tid: tid, - after: parseInt($('#post-container .post-row.infiniteloaded').last().attr('data-index'), 10) + 1 - }, function (err, data) { - if(err) { - return app.alertError(err.message); - } + socket.emit('topics.loadMore', { + tid: tid, + after: parseInt($('#post-container .post-row.infiniteloaded').last().attr('data-index'), 10) + 1 + }, function (err, data) { + if(err) { + return app.alertError(err.message); + } - infiniteLoaderActive = false; - if (data && data.posts && data.posts.length) { - indicatorEl.attr('done', '0'); - createNewPosts(data, true); - } else { - indicatorEl.attr('done', '1'); - } - indicatorEl.fadeOut(); - if (callback) { - callback(data.posts); - } - }); + infiniteLoaderActive = false; + if (data && data.posts && data.posts.length) { + indicatorEl.attr('done', '0'); + createNewPosts(data, true); + } else { + indicatorEl.attr('done', '1'); + updateHeader(); + } + + indicatorEl.fadeOut(); + + if (callback) { + callback(data.posts); + } + }); + } } return Topic; diff --git a/src/socket.io/topics.js b/src/socket.io/topics.js index d79bb1b8a6..5e71ee0022 100644 --- a/src/socket.io/topics.js +++ b/src/socket.io/topics.js @@ -204,7 +204,9 @@ SocketTopics.loadMore = function(socket, data, callback) { end = start + 9; topics.getTopicPosts(data.tid, start, end, socket.uid, function(err, posts) { - callback(err, {posts: posts}); + setTimeout(function() { + callback(err, {posts: posts}); + }, 2500); }); };