From 4cf0af055688388345712c9282d9870bc83e392d Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Thu, 16 May 2013 12:47:21 -0400 Subject: [PATCH] fixed topics --- src/posts.js | 159 ++++++++++++++++++++++++++++----------------------- 1 file changed, 86 insertions(+), 73 deletions(-) diff --git a/src/posts.js b/src/posts.js index 2c74859dcb..403461a56e 100644 --- a/src/posts.js +++ b/src/posts.js @@ -18,7 +18,10 @@ marked.setOptions({ var post_data, user_data, thread_data, vote_data, viewer_data; - topics.markAsRead(tid, current_user); + getTopicPosts(); + + getUserReputation(); + //compile thread after all data is asynchronously called function generateThread() { @@ -71,84 +74,94 @@ marked.setOptions({ }); } + function getTopicPosts() { + // get all data for thread in asynchronous fashion + RDB.lrange('tid:' + tid + ':posts', start, end, function(err, pids) { + RDB.handle(err); + + if(pids.length === 0 ){ + callback(false); + return; + } + + topics.markAsRead(tid, current_user); + + var content = [], uid = [], timestamp = [], pid = [], post_rep = [], editor = [], editTime = [], deleted = []; + + for (var i=0, ii=pids.length; i