rejigged Topics.get so that it does not return a hardcoded return if no topics were returned

v1.18.x
Julian Lam
parent 785e49c8d9
commit 3df8d7279b

@ -75,7 +75,6 @@ marked.setOptions({
active_usernames = replies[1];
var topics = [];
if (tids.length > 0) {
title = replies[2];
uid = replies[3];
timestamp = replies[4];
@ -93,6 +92,7 @@ marked.setOptions({
function generate_topic() {
if (!usernames || !has_read || !moderators || !teaser_info) return;
if (tids.length > 0) {
for (var i=0, ii=title.length; i<ii; i++) {
topics.push({
'title' : title[i],
@ -111,6 +111,7 @@ marked.setOptions({
'teaser_username': teaser_info[i].username
});
}
}
// Float pinned topics to the top
topics = topics.sort(function(a, b) {
@ -156,15 +157,14 @@ marked.setOptions({
teaser_info = teasers;
generate_topic();
});
}
else {
callback({
'category_name' : category_id ? category_name : 'Recent',
'show_topic_button' : category_id ? 'show' : 'hidden',
'category_id': category_id || 0,
'topics': []
});
}
// else {
// callback({
// 'category_name' : category_id ? category_name : 'Recent',
// 'show_topic_button' : category_id ? 'show' : 'hidden',
// 'category_id': category_id || 0,
// 'topics': []
// });
// }
});
});
}

@ -447,9 +447,10 @@ var config = require('../config.js'),
};
User.get_usernames_by_uids = function(uids, callback) {
var usernames = [];
if (!Array.isArray(uids)) return callback([]);
for(var i=0, ii=uids.length; i<ii; ++i) {
User.getUserField(uids[i],'username', function(username){

Loading…
Cancel
Save