From 98013536d1ebb09a1912226a4d60c2dc4299c423 Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Wed, 3 Jul 2013 12:14:20 -0400 Subject: [PATCH] more fixes --- public/templates/noscript/topic.tpl | 4 +- src/favourites.js | 5 +- src/postTools.js | 60 -------------- src/posts.js | 10 ++- src/schema.js | 13 ---- src/threadTools.js | 11 ++- src/topics.js | 116 +++++++++++++++++----------- src/webserver.js | 8 +- src/websockets.js | 20 +++-- 9 files changed, 106 insertions(+), 141 deletions(-) diff --git a/public/templates/noscript/topic.tpl b/public/templates/noscript/topic.tpl index b1581ddbe6..c9a259a6cd 100644 --- a/public/templates/noscript/topic.tpl +++ b/public/templates/noscript/topic.tpl @@ -3,7 +3,7 @@
  • -
    +
    {main_posts.username}
    @@ -16,7 +16,7 @@
  • -
    +
    {posts.username}
    diff --git a/src/favourites.js b/src/favourites.js index 3737e1cc66..675a9fa285 100644 --- a/src/favourites.js +++ b/src/favourites.js @@ -91,9 +91,10 @@ var RDB = require('./redis.js'), data[post_id] = hasFavourited; loaded ++; - if (loaded == pids.length) callback(data); + if (loaded === pids.length) + callback(data); }); - }(pids[i])) + }(pids[i])); } } diff --git a/src/postTools.js b/src/postTools.js index 46fec16701..e54cef7061 100644 --- a/src/postTools.js +++ b/src/postTools.js @@ -116,65 +116,5 @@ marked.setOptions({ }); } - PostTools.constructPostObject = function(rawPosts, tid, current_user, privileges, callback) { - var postObj = []; - - async.waterfall([ - function(next) { - if (!privileges) { - threadTools.privileges(tid, current_user, function(privs) { - privileges = privs; - next(); - }); - } else { - next(); - } - }, - function(next) { - var postData = rawPosts.postData, - userData = rawPosts.userData, - voteData = rawPosts.voteData; - - if (!postData) { - return next(null, []); - } - - for (var i=0, ii= postData.pid.length; i 0) { if (parseInt(data.tid) > 0) { - topics.get_topic(data.tid, uid, function(topicData) { - topicData.tid = data.tid; - if (data.body) topicData.body = data.body; + topics.getTopicData(data.tid, function(topicData) { + + if (data.body) + topicData.body = data.body; + socket.emit('api:composer.push', { tid: data.tid, title: topicData.title @@ -416,14 +418,10 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }), var start = data.after, end = start + 10; - posts.getPostsByTid(data.tid, start, end, function(posts){ - if (!posts.error) { - postTools.constructPostObject(posts, data.tid, uid, null, function(postObj) { - io.sockets.in('topic_' + data.tid).emit('event:new_post', { - posts: postObj - }); - }); - } + topics.getTopicPosts(data.tid, start, end, uid, function(posts) { + io.sockets.in('topic_' + data.tid).emit('event:new_post', { + posts: posts + }); }); });