fixed home loading

v1.18.x
Baris Usakli
parent e69928d624
commit e979d1bf0d

@ -186,6 +186,11 @@ var RDB = require('./redis.js'),
Categories.getRecentReplies = function(cid, count, callback) { Categories.getRecentReplies = function(cid, count, callback) {
RDB.zrevrange('categories:recent_posts:cid:' + cid, 0, (count<10)?10:count, function(err, pids) { RDB.zrevrange('categories:recent_posts:cid:' + cid, 0, (count<10)?10:count, function(err, pids) {
if(err) {
console.log(err);
callback([]);
return;
}
if (pids.length == 0) { if (pids.length == 0) {
callback([]); callback([]);

@ -60,7 +60,7 @@ var RDB = require('./redis.js'),
function getPostSummary(pid, callback) { function getPostSummary(pid, callback) {
Posts.getPostFields(pid, ['pid', 'tid', 'content', 'uid', 'timestamp', 'deleted'], function(postData) { Posts.getPostFields(pid, ['pid', 'tid', 'content', 'uid', 'timestamp', 'deleted'], function(postData) {
if(postData.deleted === '1') { if(postData.deleted === '1') {
return; return callback(null);
} }
Posts.addUserInfoToPost(postData, function() { Posts.addUserInfoToPost(postData, function() {
@ -81,6 +81,8 @@ var RDB = require('./redis.js'),
async.eachSeries(pids, getPostSummary, function(err) { async.eachSeries(pids, getPostSummary, function(err) {
if(!err) { if(!err) {
callback(returnData); callback(returnData);
} else {
console.log(err);
} }
}); });
}; };

@ -17,7 +17,7 @@ var user = require('./../user.js'),
app.get('/api/home', function(req, res) { app.get('/api/home', function(req, res) {
var uid = (req.user) ? req.user.uid : 0; var uid = (req.user) ? req.user.uid : 0;
categories.getAllCategories(function(data) { categories.getAllCategories(function(data) {
data.categories = data.categories.filter(function(category) { data.categories = data.categories.filter(function(category) {
return (!category.disabled || category.disabled === "0"); return (!category.disabled || category.disabled === "0");
}); });
@ -26,16 +26,17 @@ var user = require('./../user.js'),
categories.getRecentReplies(category.cid, 2, function(posts) { categories.getRecentReplies(category.cid, 2, function(posts) {
category["posts"] = posts; category["posts"] = posts;
category["post_count"] = posts.length>2 ? 2 : posts.length; category["post_count"] = posts.length>2 ? 2 : posts.length;
console.log(category.cid, 'worked');
callback(null); callback(null);
}); });
} }
require('async').each(data.categories, iterator, function(err) { require('async').each(data.categories, iterator, function(err) {
data.motd_class = (config.show_motd === '1' || config.show_motd === undefined) ? '' : 'none'; data.motd_class = (config.show_motd === '1' || config.show_motd === undefined) ? '' : 'none';
data.motd = marked(config.motd || "# NodeBB v" + pkg.version + "\nWelcome to NodeBB, the discussion platform of the future.\n\n<a target=\"_blank\" href=\"http://www.nodebb.org\" class=\"btn btn-large\"><i class=\"icon-comment\"></i> Get NodeBB</a> <a target=\"_blank\" href=\"https://github.com/designcreateplay/NodeBB\" class=\"btn btn-large\"><i class=\"icon-github-alt\"></i> Fork us on Github</a> <a target=\"_blank\" href=\"https://twitter.com/dcplabs\" class=\"btn btn-large\"><i class=\"icon-twitter\"></i> @dcplabs</a>"); data.motd = marked(config.motd || "# NodeBB v" + pkg.version + "\nWelcome to NodeBB, the discussion platform of the future.\n\n<a target=\"_blank\" href=\"http://www.nodebb.org\" class=\"btn btn-large\"><i class=\"icon-comment\"></i> Get NodeBB</a> <a target=\"_blank\" href=\"https://github.com/designcreateplay/NodeBB\" class=\"btn btn-large\"><i class=\"icon-github-alt\"></i> Fork us on Github</a> <a target=\"_blank\" href=\"https://twitter.com/dcplabs\" class=\"btn btn-large\"><i class=\"icon-twitter\"></i> @dcplabs</a>");
res.json(data); res.json(data);
}); });
}, uid); }, uid);
}); });

Loading…
Cancel
Save