From 75ff4d7dea8bf2b1e90b7e59b97706b368f2b2ae Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 28 Jun 2019 15:32:47 -0400 Subject: [PATCH] feat: returning category data in tags page For nodebb/nodebb-theme-persona#483 --- src/controllers/tags.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/controllers/tags.js b/src/controllers/tags.js index 2dc54dd18a..4c4688b4d1 100644 --- a/src/controllers/tags.js +++ b/src/controllers/tags.js @@ -4,6 +4,7 @@ var async = require('async'); var validator = require('validator'); var user = require('../user'); +var categories = require('../categories'); var topics = require('../topics'); var privileges = require('../privileges'); var pagination = require('../pagination'); @@ -40,12 +41,19 @@ tagsController.getTag = function (req, res, next) { tids: function (next) { topics.getTagTids(req.params.tag, start, stop, next); }, + categories: function (next) { + const states = [categories.watchStates.watching, categories.watchStates.notwatching, categories.watchStates.ignoring]; + helpers.getCategoriesByStates(req.uid, '', states, next); + }, }, next); }, function (results, next) { if (Array.isArray(results.tids) && !results.tids.length) { return res.render('tag', templateData); } + + templateData.categories = results.categories.categories; + topicCount = results.topicCount; topics.getTopics(results.tids, req.uid, next); },