chore: appease codeclimate

v1.18.x
Julian Lam 4 years ago
parent 24e754d120
commit 9f62df15bd

@ -115,17 +115,7 @@ Topics.getTopicsByTids = async function (tids, options) {
result.topics.forEach(function (topic, i) { result.topics.forEach(function (topic, i) {
if (topic) { if (topic) {
topic.thumbs = result.thumbs[i]; topic.thumbs = result.thumbs[i];
// Note: Backwards compatibility with old thumb logic, remove in v1.16.0 restoreThumbValue(topic);
if (topic.thumb && !topic.thumbs.length) {
topic.thumbs = [{
id: topic.tid,
name: path.basename(topic.thumb),
url: topic.thumb,
}];
} else if (topic.thumbs.length) {
topic.thumb = topic.thumbs[0].url;
}
// end
topic.category = result.categoriesMap[topic.cid]; topic.category = result.categoriesMap[topic.cid];
topic.user = topic.uid ? result.usersMap[topic.uid] : { ...result.usersMap[topic.uid] }; topic.user = topic.uid ? result.usersMap[topic.uid] : { ...result.usersMap[topic.uid] };
if (result.tidToGuestHandle[topic.tid]) { if (result.tidToGuestHandle[topic.tid]) {
@ -153,6 +143,20 @@ Topics.getTopicsByTids = async function (tids, options) {
return hookResult.topics; return hookResult.topics;
}; };
// Note: Backwards compatibility with old thumb logic, remove in v1.16.0
function restoreThumbValue(topic) {
if (topic.thumb && !topic.thumbs.length) {
topic.thumbs = [{
id: topic.tid,
name: path.basename(topic.thumb),
url: topic.thumb,
}];
} else if (topic.thumbs.length) {
topic.thumb = topic.thumbs[0].url;
}
}
// end
Topics.getTopicWithPosts = async function (topicData, set, uid, start, stop, reverse) { Topics.getTopicWithPosts = async function (topicData, set, uid, start, stop, reverse) {
const [ const [
posts, posts,
@ -181,18 +185,7 @@ Topics.getTopicWithPosts = async function (topicData, set, uid, start, stop, rev
]); ]);
topicData.thumbs = thumbs; topicData.thumbs = thumbs;
// Note: Backwards compatibility with old thumb logic, remove in v1.16.0 restoreThumbValue(topicData);
if (topicData.thumb && !topicData.thumbs.length) {
topicData.thumbs = [{
id: topicData.tid,
name: path.basename(topicData.thumb),
url: topicData.thumb,
}];
} else if (topicData.thumbs.length) {
topicData.thumb = topicData.thumbs[0].url;
}
// end
topicData.posts = posts; topicData.posts = posts;
topicData.category = category; topicData.category = category;
topicData.tagWhitelist = tagWhitelist[0]; topicData.tagWhitelist = tagWhitelist[0];

Loading…
Cancel
Save