mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-10 17:42:52 +01:00
fix: missing teasers for remote categories on /world
This commit is contained in:
@@ -288,6 +288,7 @@ Mocks.category = async (actors) => {
|
||||
bgColor,
|
||||
backgroundImage,
|
||||
imageClass: 'cover',
|
||||
numRecentReplies: 1,
|
||||
// followerCount,
|
||||
// followingCount,
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ const topics = require('../topics');
|
||||
const privileges = require('../privileges');
|
||||
const plugins = require('../plugins');
|
||||
const batch = require('../batch');
|
||||
const utils = require('../utils');
|
||||
|
||||
module.exports = function (Categories) {
|
||||
Categories.getRecentReplies = async function (cid, uid, start, stop) {
|
||||
@@ -27,7 +28,7 @@ module.exports = function (Categories) {
|
||||
Categories.updateRecentTid = async function (cid, tid) {
|
||||
const [count, numRecentReplies] = await Promise.all([
|
||||
db.sortedSetCard(`cid:${cid}:recent_tids`),
|
||||
db.getObjectField(`category:${cid}`, 'numRecentReplies'),
|
||||
db.getObjectField(`${utils.isNumber(cid) ? 'category' : 'categoryRemote'}:${cid}`, 'numRecentReplies'),
|
||||
]);
|
||||
|
||||
if (count >= numRecentReplies) {
|
||||
@@ -131,7 +132,10 @@ module.exports = function (Categories) {
|
||||
function assignTopicsToCategories(categories, topics) {
|
||||
categories.forEach((category) => {
|
||||
if (category) {
|
||||
category.posts = topics.filter(t => t.cid && (t.cid === category.cid || t.parentCids.includes(category.cid)))
|
||||
category.posts = topics.filter(
|
||||
t => t.cid &&
|
||||
(t.cid === category.cid || (t.parentCids && t.parentCids.includes(category.cid)))
|
||||
)
|
||||
.sort((a, b) => b.timestamp - a.timestamp)
|
||||
.slice(0, parseInt(category.numRecentReplies, 10));
|
||||
}
|
||||
|
||||
@@ -68,6 +68,12 @@ controller.list = async function (req, res) {
|
||||
categories.getRecentTopicReplies(categoryData, req.uid, req.query),
|
||||
categories.setUnread(data.categories, cids, req.uid),
|
||||
]);
|
||||
data.categories.forEach((category) => {
|
||||
if (category) {
|
||||
helpers.trimChildren(category);
|
||||
helpers.setCategoryTeaser(category);
|
||||
}
|
||||
});
|
||||
|
||||
data.title = translator.escape(data.name);
|
||||
data.privileges = userPrivileges;
|
||||
|
||||
Reference in New Issue
Block a user