fix: clear children before building tree

prevents infinite loop on databases that have children array saved in database
This commit is contained in:
Barış Soner Uşaklı
2019-04-06 20:33:03 -04:00
parent 4f3ca4d899
commit 397e062a3c

View File

@@ -395,6 +395,7 @@ Categories.getTree = function (categories, parentCid) {
const parents = {}; const parents = {};
cids.forEach((cid, index) => { cids.forEach((cid, index) => {
if (cid) { if (cid) {
categories[index].children = undefined;
cidToCategory[cid] = categories[index]; cidToCategory[cid] = categories[index];
parents[cid] = _.clone(categories[index]); parents[cid] = _.clone(categories[index]);
} }