fixes to infinite load and paginator

v1.18.x
Baris Usakli 11 years ago
parent dd36cce329
commit b2074c6dda

@ -786,7 +786,7 @@ define(function() {
if (scrollTop < 50 && Topic.postCount > 1) {
localStorage.removeItem("topic:" + tid + ":bookmark");
pagination.innerHTML = '0 out of ' + Topic.postCount;
pagination.innerHTML = '1 out of ' + Topic.postCount;
return;
}
@ -812,7 +812,7 @@ define(function() {
smallestNonNegative = Number.MAX_VALUE;
}
pagination.innerHTML = this.postnumber + ' out of ' + Topic.postCount;
pagination.innerHTML = (this.postnumber-1) + ' out of ' + Topic.postCount;
}
});
@ -863,8 +863,9 @@ define(function() {
}
function createNewPosts(data, infiniteLoaded) {
if(!data || (data.posts && !data.posts.length))
if(!data || (data.posts && !data.posts.length)) {
return;
}
function removeAlreadyAddedPosts() {
data.posts = data.posts.filter(function(post) {
@ -944,7 +945,7 @@ define(function() {
socket.emit('api:topic.loadMore', {
tid: tid,
after: $('#post-container .post-row.infiniteloaded').length
after: $('#post-container .post-row.infiniteloaded').last().attr('data-index') + 1
}, function (data) {
infiniteLoaderActive = false;
if (data.posts.length) {

@ -26,7 +26,7 @@
<ul id="post-container" class="container posts" data-tid="{topic_id}">
<!-- BEGIN posts -->
<li class="row post-row infiniteloaded" data-pid="{posts.pid}" data-uid="{posts.uid}" data-username="{posts.username}" data-deleted="{posts.deleted}" itemscope itemtype="http://schema.org/Comment">
<li class="row post-row infiniteloaded" data-pid="{posts.pid}" data-uid="{posts.uid}" data-username="{posts.username}" data-index="{posts.index}" data-deleted="{posts.deleted}" itemscope itemtype="http://schema.org/Comment">
<a id="post_anchor_{posts.pid}" name="{posts.pid}"></a>
<meta itemprop="datePublished" content="{posts.relativeTime}">

@ -160,8 +160,17 @@ var RDB = require('./redis'),
Topics.getTopicPosts = function(tid, start, end, current_user, callback) {
posts.getPostsByTid(tid, start, end, function(postData) {
if (Array.isArray(postData) && !postData.length)
if (Array.isArray(postData) && !postData.length) {
return callback([]);
}
for(var i=0; i<postData.length; ++i) {
postData[i].index = start + i;
}
postData = postData.filter(function(post) {
return parseInt(current_user, 10) !== 0 || post.deleted === "0";
});
function getFavouritesData(next) {
var pids = [];
@ -482,8 +491,9 @@ var RDB = require('./redis'),
Topics.getTopicWithPosts = function(tid, current_user, start, end, callback) {
threadTools.exists(tid, function(exists) {
if (!exists)
if (!exists) {
return callback(new Error('Topic tid \'' + tid + '\' not found'));
}
Topics.markAsRead(tid, current_user);
Topics.increaseViewCount(tid);

Loading…
Cancel
Save