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