mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 00:56:13 +01:00
@@ -15,12 +15,12 @@ categoriesController.get = async function (req, res) {
|
|||||||
user.getCategoryWatchState(res.locals.uid),
|
user.getCategoryWatchState(res.locals.uid),
|
||||||
categories.buildForSelect(res.locals.uid, 'find', ['descriptionParsed', 'depth', 'slug']),
|
categories.buildForSelect(res.locals.uid, 'find', ['descriptionParsed', 'depth', 'slug']),
|
||||||
]);
|
]);
|
||||||
|
const watchCategories = allCategoriesData.filter(c => c && c.cid !== -1);
|
||||||
const pageCount = Math.max(1, Math.ceil(allCategoriesData.length / meta.config.categoriesPerPage));
|
const pageCount = Math.max(1, Math.ceil(watchCategories.length / meta.config.categoriesPerPage));
|
||||||
const page = Math.min(parseInt(req.query.page, 10) || 1, pageCount);
|
const page = Math.min(parseInt(req.query.page, 10) || 1, pageCount);
|
||||||
const start = Math.max(0, (page - 1) * meta.config.categoriesPerPage);
|
const start = Math.max(0, (page - 1) * meta.config.categoriesPerPage);
|
||||||
const stop = start + meta.config.categoriesPerPage - 1;
|
const stop = start + meta.config.categoriesPerPage - 1;
|
||||||
const categoriesData = allCategoriesData.slice(start, stop + 1);
|
const categoriesData = watchCategories.slice(start, stop + 1);
|
||||||
|
|
||||||
|
|
||||||
categoriesData.forEach((category) => {
|
categoriesData.forEach((category) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user