feat: notice on remote categories that have no local followers, #13255

This commit is contained in:
Julian Lam
2025-04-08 14:16:49 -04:00
parent f02d96614a
commit 93a5b35f33
2 changed files with 5 additions and 1 deletions

View File

@@ -7,6 +7,7 @@
"new-topic-button": "New Topic",
"guest-login-post": "Log in to post",
"no-topics": "<strong>There are no topics in this category.</strong><br />Why don't you try posting one?",
"no-followers": "Nobody on this website is tracking or watching this category. Track or watch this category in order to begin receiving updates.",
"browsing": "browsing",
"no-replies": "No one has replied",

View File

@@ -8,6 +8,7 @@ const user = require('../user');
const topics = require('../topics');
const plugins = require('../plugins');
const privileges = require('../privileges');
const activitypub = require('../activitypub');
const cache = require('../cache');
const meta = require('../meta');
const utils = require('../utils');
@@ -57,12 +58,13 @@ Categories.getCategoryById = async function (data) {
Categories.getTopicCount(data),
Categories.getWatchState([data.cid], data.uid),
getChildrenTree(category, data.uid),
!utils.isNumber(data.cid) ? activitypub.actors.getLocalFollowers(data.cid) : null,
];
if (category.parentCid) {
promises.push(Categories.getCategoryData(category.parentCid));
}
const [topics, topicCount, watchState, , parent] = await Promise.all(promises);
const [topics, topicCount, watchState, , localFollowers, parent] = await Promise.all(promises);
category.topics = topics.topics;
category.nextStart = topics.nextStart;
@@ -71,6 +73,7 @@ Categories.getCategoryById = async function (data) {
category.isTracked = watchState[0] === Categories.watchStates.tracking;
category.isNotWatched = watchState[0] === Categories.watchStates.notwatching;
category.isIgnored = watchState[0] === Categories.watchStates.ignoring;
category.hasFollowers = localFollowers ? (localFollowers.uids.size + localFollowers.cids.size) > 0 : localFollowers;
category.parent = parent;
calculateTopicPostCount(category);