mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 02:55:58 +01:00 
			
		
		
		
	feat: filter followed tids by category
This commit is contained in:
		| @@ -177,9 +177,14 @@ module.exports = function (Topics) { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	async function getFollowedTids(params) { | 	async function getFollowedTids(params) { | ||||||
| 		const tids = await db.getSortedSetsMembers(['uid:' + params.uid + ':followed_tids']); | 		let tids = (await db.getSortedSetsMembers(['uid:' + params.uid + ':followed_tids']))[0]; | ||||||
| 		const scores = await db.sortedSetScores('topics:recent', tids[0]); | 		const filterCids = params.cid && params.cid.map(cid => parseInt(cid, 10)); | ||||||
| 		const data = tids[0].map((tid, index) => ({ value: tid, score: scores[index] })); | 		if (filterCids) { | ||||||
|  | 			const topicData = await Topics.getTopicsFields(tids, ['tid', 'cid']); | ||||||
|  | 			tids = topicData.filter(t => filterCids.includes(t.cid)).map(t => t.tid); | ||||||
|  | 		} | ||||||
|  | 		const scores = await db.sortedSetScores('topics:recent', tids); | ||||||
|  | 		const data = tids.map((tid, index) => ({ value: tid, score: scores[index] })); | ||||||
| 		return data.filter(item => item.score > params.cutoff); | 		return data.filter(item => item.score > params.cutoff); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user