closes , closes

v1.18.x
barisusakli
parent 8f5bf1a7ed
commit cd99324286

@ -64,9 +64,7 @@ var async = require('async'),
category.isIgnored = results.isIgnored[0]; category.isIgnored = results.isIgnored[0];
category.topic_row_size = 'col-md-9'; category.topic_row_size = 'col-md-9';
plugins.fireHook('filter:category.get', {category: category, uid: data.uid}, function(err, data) { callback(null, category);
callback(err, data ? data.category : null);
});
}); });
}); });
}; };

@ -22,12 +22,7 @@ categoriesController.recent = function(req, res, next) {
data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1; data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1;
plugins.fireHook('filter:category.get', {category: data, uid: uid}, function(err, data) { res.render('recent', data);
if (err) {
return next(err);
}
res.render('recent', data.category);
});
}); });
}; };
@ -49,24 +44,22 @@ categoriesController.popular = function(req, res, next) {
} }
} }
topics.getPopular(term, uid, meta.config.topicsPerList, function(err, data) { topics.getPopular(term, uid, meta.config.topicsPerList, function(err, topics) {
if (err) { if (err) {
return next(err); return next(err);
} }
data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1; var data = {
topics: topics,
'feeds:disableRSS': parseInt(meta.config['feeds:disableRSS'], 10) === 1
};
plugins.fireHook('filter:category.get', {category: {topics: data}, uid: uid}, function(err, data) {
if (err) {
return next(err);
}
if (uid === 0) { if (uid === 0) {
anonCache[term] = data.category; anonCache[term] = data;
lastUpdateTime = Date.now(); lastUpdateTime = Date.now();
} }
res.render('popular', data.category); res.render('popular', data);
});
}); });
}; };
@ -78,12 +71,7 @@ categoriesController.unread = function(req, res, next) {
return next(err); return next(err);
} }
plugins.fireHook('filter:category.get', {category: data, uid: uid}, function(err, data) { res.render('unread', data);
if (err) {
return next(err);
}
res.render('unread', data.category);
});
}); });
}; };

@ -32,24 +32,21 @@ module.exports = function(Topics) {
} }
function getTopics(tids, uid, count, callback) { function getTopics(tids, uid, count, callback) {
Topics.getTopicsFields(tids, ['tid', 'postcount'], function(err, topics) { async.waterfall([
if (err) { function(next) {
return callback(err); Topics.getTopicsFields(tids, ['tid', 'postcount'], next);
} },
function(topics, next) {
tids = topics.sort(function(a, b) { tids = topics.sort(function(a, b) {
return b.postcount - a.postcount; return b.postcount - a.postcount;
}).slice(0, count).map(function(topic) { }).slice(0, count).map(function(topic) {
return topic.tid; return topic.tid;
}); });
privileges.topics.filter('read', tids, uid, next);
privileges.topics.filter('read', tids, uid, function(err, tids) { },
if (err) { function(tids, next) {
return callback(err); Topics.getTopicsByTids(tids, uid, next);
} }
], callback);
Topics.getTopicsByTids(tids, uid, callback);
});
});
} }
}; };

Loading…
Cancel
Save