Skip to content

Commit f0b4e2e

Browse files
committed
(add) removeDups function to remove duplicate components currently stored in bothObj which has all the mapping of atoms/selectors with their respective components
1 parent 04d5f69 commit f0b4e2e

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

src/app/components/AtomsRelationship.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ const clusterData : clusterShape = {};
4444
const selectorsCache :selectorsCache = {};
4545
const bothObj = {};
4646

47-
console.log('bothObj', bothObj)
4847

4948
let initialFire = false
5049
function clusterDataPopulate(props:StateRouteProps) {
@@ -144,14 +143,14 @@ function reorganizedCompObj(props) {
144143
return reorganizedCompObj;
145144
}
146145

147-
function Node({ node, snapshots, dispatch}) {
146+
function Node({ node, snapshots, dispatch, bothObj}) {
148147
// const [dispatch] = useStoreContext();
149148
const selector = node.depth === 1 && node.height === 2
150149
const isRoot = node.depth === 0;
151150
const isParent = !!node.children;
152151

153152
if (isRoot) return <RootNode node={node} />;
154-
if (selector) return <SelectorNode node = {node} snapshots = {snapshots}/>;
153+
if (selector) return <SelectorNode node = {node} snapshots = {snapshots} bothObj = {bothObj}/>;
155154

156155
return (
157156
<Group top={node.y} left={node.x}>
@@ -161,6 +160,7 @@ function Node({ node, snapshots, dispatch}) {
161160
fill={isParent ? orange : blue}
162161
stroke={isParent ? orange : blue}
163162
onMouseEnter={()=> {
163+
console.log(bothObj)
164164
console.log(clusterData)
165165
console.log(snapshots[0].recoilDomNode)
166166
console.log(node.data.name)
@@ -219,7 +219,7 @@ function RootNode({ node }) {
219219
);
220220
}
221221

222-
function SelectorNode({ node, snapshots, dispatch}) {
222+
function SelectorNode({ node, snapshots, dispatch, bothObj}) {
223223
// const [dispatch] = useStoreContext();
224224
return (
225225
<Group top={node.y} left={node.x}>
@@ -229,6 +229,7 @@ function SelectorNode({ node, snapshots, dispatch}) {
229229
fill={selectWhite}
230230
stroke={selectWhite}
231231
onMouseEnter={()=> {
232+
console.log(bothObj)
232233
console.log(clusterData)
233234
console.log(snapshots[0].recoilDomNode)
234235
console.log(node.data.name)
@@ -252,6 +253,15 @@ function SelectorNode({ node, snapshots, dispatch}) {
252253
);
253254
}
254255

256+
function removeDup(bothObj){
257+
let filteredObj = {}
258+
for (let key in bothObj){
259+
let array = bothObj[key].filter((a,b) => bothObj[key].indexOf(a) === b)
260+
filteredObj[key] = array
261+
}
262+
return filteredObj
263+
}
264+
255265
const defaultMargin = { top: 40, left: 0, right: 0, bottom: 40 };
256266

257267
// export type DendrogramProps = {
@@ -266,6 +276,10 @@ export default function AtomsRelationship({
266276
margin = defaultMargin,
267277
snapshots,
268278
}) {
279+
280+
281+
let filtered = removeDup(bothObj)
282+
269283
const [dispatch] = useStoreContext();
270284
if(!initialFire){
271285
clusterDataPopulate(snapshots);
@@ -302,6 +316,7 @@ export default function AtomsRelationship({
302316
{cluster.descendants().map((node, i) => (
303317
<Node key={`cluster-node-${i}`}
304318
node={node}
319+
bothObj = {bothObj}
305320
snapshots = {snapshots}
306321
dispatch = {dispatch} />
307322
))}

0 commit comments

Comments
 (0)