From 1545223e7f00ef544a82d9afad7a54f1b1ccdcc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 8 Mar 2023 18:28:55 -0500 Subject: [PATCH] fix: tag filtering when changing filter to watched topics or changing popular time limit to month --- src/topics/sorted.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/topics/sorted.js b/src/topics/sorted.js index af2cd344cb..7899a2f8d0 100644 --- a/src/topics/sorted.js +++ b/src/topics/sorted.js @@ -174,7 +174,7 @@ module.exports = function (Topics) { } tids = await privileges.topics.filterTids('topics:read', tids, uid); - let topicData = await Topics.getTopicsFields(tids, ['uid', 'tid', 'cid']); + let topicData = await Topics.getTopicsFields(tids, ['uid', 'tid', 'cid', 'tags']); const topicCids = _.uniq(topicData.map(topic => topic.cid)).filter(Boolean); async function getIgnoredCids() { @@ -192,11 +192,13 @@ module.exports = function (Topics) { topicData = filtered; const cids = params.cids && params.cids.map(String); + const { tags } = params; tids = topicData.filter(t => ( t && t.cid && !isCidIgnored[t.cid] && - (!cids || cids.includes(String(t.cid))) + (!cids || cids.includes(String(t.cid))) && + (!tags.length || tags.every(tag => t.tags.find(topicTag => topicTag.value === tag))) )).map(t => t.tid); const result = await plugins.hooks.fire('filter:topics.filterSortedTids', { tids: tids, params: params });