fixes to infinite load and paginator

This commit is contained in:
Baris Usakli
2013-11-29 13:09:26 -05:00
parent dd36cce329
commit b2074c6dda
3 changed files with 18 additions and 7 deletions

View File

@@ -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);