diff --git a/public/templates/admin/topics.tpl b/public/templates/admin/topics.tpl
index 68d58e2c19..e0d0a79343 100644
--- a/public/templates/admin/topics.tpl
+++ b/public/templates/admin/topics.tpl
@@ -12,7 +12,7 @@
{topics.title}
- Posted {topics.relativeTime} ago by {topics.username}
- - {topics.post_count} post(s)
+ - {topics.postcount} post(s)
diff --git a/public/templates/category.tpl b/public/templates/category.tpl
index 50d7d3864d..2f39054da0 100644
--- a/public/templates/category.tpl
+++ b/public/templates/category.tpl
@@ -30,7 +30,7 @@
-
{topics.post_count}{topics.title}
+
{topics.postcount}{topics.title}
Posted {topics.relativeTime} ago by
diff --git a/public/templates/noscript/category.tpl b/public/templates/noscript/category.tpl
index 3aeb8ddc87..0d44ed3376 100644
--- a/public/templates/noscript/category.tpl
+++ b/public/templates/noscript/category.tpl
@@ -6,7 +6,7 @@
-
{topics.post_count}{topics.title}
+ {topics.postcount}{topics.title}
Posted {topics.relativeTime} ago by
diff --git a/src/categories.js b/src/categories.js
index 2032a52c99..7e2d3a50fa 100644
--- a/src/categories.js
+++ b/src/categories.js
@@ -57,7 +57,7 @@ var RDB = require('./redis.js'),
}
function getActiveUsers(next) {
- user.getMultipleUserFields(active_users, ['username','userslug'], function(users) {
+ user.getMultipleUserFields(active_users, ['username', 'userslug'], function(users) {
var activeUserData = [];
for(var uid in users) {
activeUserData.push(users[uid]);
@@ -117,7 +117,7 @@ var RDB = require('./redis.js'),
Categories.getTopicsByTids = function(tids, current_user, callback, category_id /*temporary*/) {
var retrieved_topics = [];
- function getTopicInfoMoar(topicData, callback) {
+ function getTopicInfo(topicData, callback) {
function getUserName(next) {
user.getUserField(topicData.uid, 'username', function(username) {
@@ -152,33 +152,20 @@ var RDB = require('./redis.js'),
callback({
username: username,
- hasReadTopic: hasReadTopic,
+ hasread: hasReadTopic,
teaserInfo: teaserInfo,
privileges: privileges
});
- //if (!deleted[i] || (deleted[i] && privileges.view_deleted) || uid[i] === current_user) {
- /*retrieved_topics.push({
-
- 'username': usernames[i],
- 'badgeclass' : (hasReadTopics[i] && current_user !=0) ? '' : 'badge-important',
- 'teaser_text': teaserInfo[i].text,
- 'teaser_username': teaserInfo[i].username,
- 'teaser_timestamp': utils.relativeTime(teaserInfo[i].timestamp)
- });*/
- //}
-
-
-
});
}
-
+
+ var topicCountToLoad = tids.length;
for(var i=0; i 0) {
RDB.sismember(schema.topics(tid).read_by_uid, uid, function(err, read) {
- topicData.badgeclass = read ? '' : 'badge-important';
-
- next();
+ next(null, read);
});
} else {
- next();
+ next(null, null);
}
}
function get_teaser(next) {
Topics.get_teaser(tid, function(teaser) {
- topicData.teaser_text = teaser.text;
- topicData.teaser_username = teaser.username;
-
- next();
+ next(null, teaser);
});
}
- async.parallel([get_topic_data, get_read_status, get_teaser], function(err) {
+ async.parallel([get_topic_data, get_read_status, get_teaser], function(err, results) {
if (err) {
throw new Error(err);
}
+
+ var topicData = results[0];
+ topicData.relativeTime = utils.relativeTime(results[0].timestamp);
+ topicData.badgeclass = results[1] ? '' : 'badge-important';
+ topicData.teaser_text = results[2].text;
+ topicData.teaser_username = results[2].username;
- topicData.tid = tid;
callback(topicData);
});
}
@@ -213,16 +190,6 @@ marked.setOptions({
});
}
- Topics.get_cid_by_tid = function(tid, callback) {
- RDB.get(schema.topics(tid).cid, function(err, cid) {
- if (cid && parseInt(cid) > 0) {
- callback(cid);
- } else {
- callback(false);
- }
- });
- }
-
Topics.getTitleByPid = function(pid, callback) {
posts.getPostField(pid, 'tid', function(tid) {
Topics.getTopicField(tid, 'title', function(title) {
@@ -235,7 +202,7 @@ marked.setOptions({
RDB.sadd(schema.topics(tid).read_by_uid, uid);
- Topics.get_cid_by_tid(tid, function(cid) {
+ Topics.getTopicField(tid, 'cid', function(cid) {
categories.isTopicsRead(cid, uid, function(read) {
if(read) {
@@ -390,6 +357,7 @@ marked.setOptions({
// Notify any users looking at the category that a new topic has arrived
Topics.get_topic(tid, uid, function(topicData) {
+
io.sockets.in('category_' + category_id).emit('event:new_topic', topicData);
io.sockets.in('recent_posts').emit('event:new_topic', topicData);
});
diff --git a/src/webserver.js b/src/webserver.js
index e17cc40929..ef6ef1f96c 100644
--- a/src/webserver.js
+++ b/src/webserver.js
@@ -301,9 +301,9 @@ var express = require('express'),
res.send(data);
});*/
- /*posts.getPostsByTid(1, 1, 0, 10, function(data) {
+ posts.getPostsByTid(2, 0, -1, function(data) {
res.send(data);
- });*/
+ });
/* posts.getPostsByPids([1,2,3], function(data) {
res.send(data);
@@ -317,10 +317,10 @@ var express = require('express'),
res.send(data);
});*/
- categories.getCategoryById(12, 0, function(returnData) {
+/* categories.getCategoryById(12, 0, function(returnData) {
res.send(returnData);
});
-
+*/
});