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

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

Loading…
Cancel
Save