fix: properly handle empty fields param

This commit is contained in:
Julian Lam
2024-03-15 12:07:33 -04:00
parent 7af0715146
commit c76d4018f2

View File

@@ -38,11 +38,14 @@ module.exports = function (Categories) {
// Handle cid -1
if (cids.includes(-1)) {
const subset = fields.reduce((category, field) => {
let subset = null;
if (fields && fields.length) {
subset = fields.reduce((category, field) => {
category[field] = worldCategory[field] || undefined;
return category;
}, {});
categories.splice(cids.indexOf(-1), 1, subset);
}
categories.splice(cids.indexOf(-1), 1, subset || worldCategory);
}
const result = await plugins.hooks.fire('filter:category.getFields', {