Node.js based forum software built for the modern web
feat: add filter:categories.categorySearch
Barış Soner Uşaklıbe19f27f4078
diff --git a/public/src/modules/categorySearch.js b/public/src/modules/categorySearch.jsindex bae1b60c9c..cf9a42bad4 100644--- a/public/src/modules/categorySearch.js+++ b/public/src/modules/categorySearch.js@@ -66,9 +66,10 @@ define('categorySearch', function () {searchEl.find('input').off('keyup');});- function loadList(query, callback) {+ function loadList(search, callback) {socket.emit('categories.categorySearch', {- query: query,+ search: search,+ query: utils.params(),parentCid: options.parentCid || 0,selectedCids: options.selectedCids,privilege: options.privilege,diff --git a/src/socket.io/categories/search.js b/src/socket.io/categories/search.jsindex 1affc248e5..dc7e6c027d 100644--- a/src/socket.io/categories/search.js+++ b/src/socket.io/categories/search.js@@ -6,6 +6,7 @@ const meta = require('../../meta');const categories = require('../../categories');const privileges = require('../../privileges');const controllersHelpers = require('../../controllers/helpers');+const plugins = require('../../plugins');module.exports = function (SocketCategories) {// used by categorySearch module@@ -17,7 +18,7 @@ module.exports = function (SocketCategories) {state => categories.watchStates[state]);- if (data.query) {+ if (data.search) {({ cids, matchedCids } = await findMatchedCids(socket.uid, data));} else {cids = await loadCids(socket.uid, data.parentCid);@@ -40,13 +41,18 @@ module.exports = function (SocketCategories) {category.match = true;}});- return categoriesData;+ const result = await plugins.hooks.fire('filter:categories.categorySearch', {+ categories: categoriesData,+ ...data,+ uid: socket.uid,+ })+ return result.categories;};async function findMatchedCids(uid, data) {const result = await categories.search({uid: uid,- query: data.query,+ query: data.search,paginate: false,});