recent posts done (needs polish/cleanup), and fixed bug where new topic button was not showing up in categories

v1.18.x
psychobunny 12 years ago
parent 6acc07920e
commit 4b67f8573e

@ -79,7 +79,7 @@ var RDB = require('./redis.js'),
var categoryData = {
'category_name' : category_name,
'show_topic_button' : 'hidden',
'show_topic_button' : 'show',
'category_id': category_id,
'active_users': active_users,
'topics' : []
@ -118,6 +118,28 @@ var RDB = require('./redis.js'),
});
}
// not the permanent location for this function
Categories.getLatestTopics = function(current_user, start, end, callback) {
RDB.zrange('topics:recent', 0, -1, function(err, tids) {
var latestTopics = {
'category_name' : 'Recent',
'show_topic_button' : 'hidden',
'category_id': false,
'topics' : []
};
if (!tids.length) {
callback(latestTopics);
return;
}
Categories.getTopicsByTids(tids, current_user, function(topicData) {
latestTopics.topics = topicData;
callback(latestTopics);
});
});
}
Categories.getTopicsByTids = function(tids, current_user, callback, category_id /*temporary*/) {
var title = [],
@ -182,10 +204,6 @@ var RDB = require('./redis.js'),
// temporary. I don't think this call should belong here
function getPrivileges(next) {
if (category_id == null) {
next(null, {view_deleted: false});
}
Categories.privileges(category_id, current_user, function(user_privs) {
next(null, user_privs);
});

@ -340,6 +340,9 @@ marked.setOptions({
// let everyone know that there is an unread topic in this category
RDB.del('cid:' + category_id + ':read_by_uid');
RDB.zadd('topics:recent', (new Date()).getTime(), tid);
//RDB.zadd('topics:active', tid);
// in future it may be possible to add topics to several categories, so leaving the door open here.
RDB.sadd('categories:' + category_id + ':tid', tid);
RDB.set('tid:' + tid + ':cid', category_id);

@ -183,17 +183,12 @@ var express = require('express'),
}, req.params.id, (req.user) ? req.user.uid : 0);
break;
case 'latest' :
categories.get(function(data) {
if(!data) {
res.send(false);
return;
}
categories.getLatestTopics((req.user) ? req.user.uid : 0, 0, 9, function(data) {
res.send(JSON.stringify(data));
});
break;
case 'popular' :
categories.get(function(data) {
console.log(data);
if(!data) {
res.send(false);
return;

Loading…
Cancel
Save