shorter code

v1.18.x
Barış Soner Uşaklı 6 years ago
parent 412358b070
commit ed7399f9ed

@ -30,20 +30,12 @@ module.exports = function (Topics) {
if (topic.teaserPid === 'null') { if (topic.teaserPid === 'null') {
delete topic.teaserPid; delete topic.teaserPid;
} }
if (meta.config.teaserPid === 'first') {
switch (meta.config.teaserPost) {
case 'first':
teaserPids.push(topic.mainPid); teaserPids.push(topic.mainPid);
break; } else if (meta.config.teaserPid === 'last-post') {
case 'last-post':
teaserPids.push(topic.teaserPid || topic.mainPid); teaserPids.push(topic.teaserPid || topic.mainPid);
break; } else if (meta.config.teaserPid === 'last-reply') {
case 'last-reply': // intentional fall-through
default:
teaserPids.push(topic.teaserPid); teaserPids.push(topic.teaserPid);
break;
} }
} }
}); });
@ -53,16 +45,12 @@ module.exports = function (Topics) {
posts.getPostsFields(teaserPids, ['pid', 'uid', 'timestamp', 'tid', 'content'], next); posts.getPostsFields(teaserPids, ['pid', 'uid', 'timestamp', 'tid', 'content'], next);
}, },
function (_postData, next) { function (_postData, next) {
_postData = _postData.filter(function (post) { _postData = _postData.filter(post => post && post.pid);
return post && parseInt(post.pid, 10);
});
handleBlocks(uid, _postData, next); handleBlocks(uid, _postData, next);
}, },
function (_postData, next) { function (_postData, next) {
postData = _postData.filter(Boolean); postData = _postData.filter(Boolean);
var uids = _.uniq(postData.map(function (post) { const uids = _.uniq(postData.map(post => post.uid));
return post.uid;
}));
user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture'], next); user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture'], next);
}, },

Loading…
Cancel
Save