From 7db7d190bf655659746e161ea484e161b8463383 Mon Sep 17 00:00:00 2001 From: Braulio Rivas Abad Date: Fri, 16 Aug 2024 09:54:40 -0500 Subject: [PATCH] fix reconnect, it was working with relations instead of objects --- js/filters/reconnect/mcparticletree.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/js/filters/reconnect/mcparticletree.js b/js/filters/reconnect/mcparticletree.js index 58395c2..9561254 100644 --- a/js/filters/reconnect/mcparticletree.js +++ b/js/filters/reconnect/mcparticletree.js @@ -9,19 +9,18 @@ const findParticles = (otherObject, relationName, ids) => { } const relations = oneToManyRelations[relationName]; + const relationObjects = relations.map((relation) => relation.to); - if (relations.length === 0) return []; + if (relationObjects.length === 0) return []; - let hasAny = 0; - - relations.forEach((object) => - ids.has(`${object.index}-${object.collectionId}`) ? (hasAny += 1) : null + relationObjects.filter((object) => + ids.has(`${object.index}-${object.collectionId}`) ); - return hasAny > 0 - ? relations - : relations - .map((parentLink) => findParticles(parentLink.to, relationName, ids)) + return relationObjects.length > 0 + ? relationObjects + : relationObjects + .map((object) => findParticles(object, relationName, ids)) .flat(); };