[Solved] Help with hook on getting recent topic topics
-
Hello everyone! I have the following issue while developing a new theme for NodeBB.
We are adding upvote/downvote capability to topics from the topics list like in the following image
In order to add voting/downvoting to theme topics from the categories list like the following we added this method
library.getCategoryHook = async function(data) { const topics = data.topics; const uid = data.uid; const promises = topics.map(async (topic) => { const hasVoted = await posts.hasVoted(topic.mainPid, uid); return { ...topic, upvoted: hasVoted.upvoted, downvoted: hasVoted.downvoted, enableVoting: uid !== 0 && data.uid !== topic.uid } }); data.topics = await Promise.all(promises); return data; }
This is called using the hook
filter:category.topics.get
and it works for the topics list but if I try to go to the recent topics view, this hook is not called. Other possibility would be to load the information on page enter but I'm not sure how to do that, any suggestions?Thanks for any help
-
@asdrubalivan have you tried using
filter:topics.get
instead? I'd think it would cover both cases. -
No. I just tried and it works @PitaJ. I just changed the hook and it worked. Thank you so much! This is now solved