show topics on home instead of replies

no template changes, instead of showing the latest x posts under
categories, we are now showing the latest x posts of the latest x
topics.
v1.18.x
barisusakli 11 years ago
parent 3e252187ad
commit 1e6d589080

@ -10,7 +10,7 @@ var async = require('async'),
module.exports = function(Categories) {
Categories.getRecentReplies = function(cid, uid, count, callback) {
if(!parseInt(count, 10)) {
if (!parseInt(count, 10)) {
return callback(null, []);
}
@ -23,6 +23,26 @@ module.exports = function(Categories) {
});
};
Categories.getRecentTopicReplies = function(cid, uid, count, callback) {
if (!parseInt(count, 10)) {
return callback(null, []);
}
db.getSortedSetRevRange('categories:' + cid + ':tid', 0, count - 1, function(err, tids) {
if (err || !tids || !tids.length) {
return callback(err, []);
}
async.map(tids, topics.getLatestUndeletedPid, function(err, pids) {
pids = pids.filter(function(pid) {
return !!pid;
});
posts.getPostSummaryByPids(pids, {stripTags: true}, callback);
});
});
};
Categories.moveRecentReplies = function(tid, oldCid, cid) {
function movePost(postData, next) {
async.parallel([

@ -70,7 +70,7 @@ Controllers.home = function(req, res, next) {
}
function getRecentReplies(category, callback) {
categories.getRecentReplies(category.cid, uid, parseInt(category.numRecentReplies, 10), function (err, posts) {
categories.getRecentTopicReplies(category.cid, uid, parseInt(category.numRecentReplies, 10), function (err, posts) {
if (err) {
return callback(err);
}

Loading…
Cancel
Save