feat: filter out topics in cid -1 from tagged topics page, closes #12489

This commit is contained in:
Julian Lam
2024-04-09 15:13:27 -04:00
parent fcd5447cd4
commit d437d969cc

View File

@@ -25,7 +25,7 @@ tagsController.getTag = async function (req, res) {
breadcrumbs: helpers.buildBreadcrumbs([{ text: '[[tags:tags]]', url: '/tags' }, { text: tag }]), breadcrumbs: helpers.buildBreadcrumbs([{ text: '[[tags:tags]]', url: '/tags' }, { text: tag }]),
title: `[[pages:tag, ${tag}]]`, title: `[[pages:tag, ${tag}]]`,
}; };
const [settings, cids, categoryData, canPost, isPrivileged, rssToken, isFollowing] = await Promise.all([ let [settings, cids, categoryData, canPost, isPrivileged, rssToken, isFollowing] = await Promise.all([
user.getSettings(req.uid), user.getSettings(req.uid),
cid || categories.getCidsByPrivilege('categories:cid', req.uid, 'topics:read'), cid || categories.getCidsByPrivilege('categories:cid', req.uid, 'topics:read'),
helpers.getSelectedCategory(cid), helpers.getSelectedCategory(cid),
@@ -34,6 +34,14 @@ tagsController.getTag = async function (req, res) {
user.auth.getFeedToken(req.uid), user.auth.getFeedToken(req.uid),
topics.isFollowingTag(req.params.tag, req.uid), topics.isFollowingTag(req.params.tag, req.uid),
]); ]);
// Explicitly exclude cid -1 if cid not specified
if (!cid) {
cids = new Set(cids);
cids.delete(-1);
cids = Array.from(cids);
}
const start = Math.max(0, (page - 1) * settings.topicsPerPage); const start = Math.max(0, (page - 1) * settings.topicsPerPage);
const stop = start + settings.topicsPerPage - 1; const stop = start + settings.topicsPerPage - 1;