perf: don't load thumbs if disabled globally, cache thumb results

This commit is contained in:
Barış Soner Uşaklı
2020-12-14 21:24:46 -05:00
parent ff18cdfa39
commit 2d5a224b06
2 changed files with 26 additions and 7 deletions

View File

@@ -145,13 +145,14 @@ Topics.getTopicsByTids = async function (tids, options) {
// Note: Backwards compatibility with old thumb logic, remove in v1.17.0
function restoreThumbValue(topic) {
if (topic.thumb && !topic.thumbs.length) {
const isArray = Array.isArray(topic.thumbs);
if (isArray && !topic.thumbs.length && topic.thumb) {
topic.thumbs = [{
id: topic.tid,
name: path.basename(topic.thumb),
url: topic.thumb,
}];
} else if (topic.thumbs.length) {
} else if (isArray && topic.thumbs.length) {
topic.thumb = topic.thumbs[0].url;
}
}