enabling infinite post loader (re: issue #42), fixes #42

This commit is contained in:
Julian Lam
2013-06-26 13:38:05 -04:00
parent 9df0b39a5d
commit 936a284397
3 changed files with 40 additions and 20 deletions

View File

@@ -17,16 +17,17 @@ marked.setOptions({
Posts.getPostsByTid = function(tid, current_user, start, end, callback) {
RDB.lrange('tid:' + tid + ':posts', start, end, function(err, pids) {
RDB.handle(err);
if (pids.length === 0 ) {
throw new Error('Topic should never have 0 posts. tid: ' + tid);
}
topics.markAsRead(tid, current_user);
Posts.getPostsByPids(pids, current_user, function(posts) {
callback(posts);
});
if (pids.length) {
Posts.getPostsByPids(pids, current_user, function(posts) {
callback(posts);
});
} else {
callback({
error: 'no-posts'
});
}
});
}