Skip to content

Commit 1395385

Browse files
committed
(add,modify) Added logic to parse through atom/selectors relationship and feed it into D3
1 parent b73f63d commit 1395385

File tree

3 files changed

+81
-29
lines changed

3 files changed

+81
-29
lines changed

src/app/components/AtomsRelationship.jsx

Lines changed: 80 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,52 +21,106 @@ const root = '#d2f5e3';
2121
//
2222

2323
const clusterData = {};
24-
let memoizeObj = {};
24+
let memoizeObjSelectors = {};
2525

2626
function clusterDataPopulate(props) {
27-
let atomCompObj = reorganizedObj(props);
28-
27+
let atomCompObj = reorganizedCompObj(props);
28+
console.log(props)
29+
console.log(atomCompObj)
30+
31+
//this is to set the root name property
2932
if (props[0].name) {
3033
clusterData.name = props[0].name;
3134
}
3235

33-
let counter = 0;
36+
//internal counter for the array
37+
let ocounter = 0;
38+
let icounter = 0
3439
for (let key in atomCompObj) {
35-
if (atomCompObj[key].length) {
36-
for (let i = 0; i < atomCompObj[key].length; i++) {
37-
if (!memoizeObj[key]) {
38-
memoizeObj[key] = [];
39-
if (!clusterData.children) clusterData.children = [];
40-
clusterData.children.push({ name: key });
41-
}
42-
if (!memoizeObj[key].includes(atomCompObj[key][i])) {
43-
if (!clusterData.children[counter].children)
44-
clusterData.children[counter].children = [];
45-
clusterData.children[counter].children.push({
46-
name: atomCompObj[key][i],
47-
});
48-
}
49-
memoizeObj[key].push(atomCompObj[key][i]);
40+
41+
if(props[0].atomSelectors[key]){
42+
if(!clusterData.children){
43+
clusterData.children = []
44+
}
45+
//need to handle duplicates
46+
clusterData.children.push({ name: key });
47+
48+
if(props[0].atomSelectors[key].length){
49+
for(let i=0; i<props[0].atomSelectors[key].length;i++){
50+
if(!clusterData.children[ocounter].children){
51+
clusterData.children[ocounter].children = []
52+
}
53+
clusterData.children[ocounter].children.push({
54+
name: props[0].atomSelectors[key][i]
55+
})
56+
for(let i=0;i<clusterData.children[ocounter].children[icounter])
57+
58+
}
59+
}
60+
outercounter++
61+
}
62+
}
63+
64+
console.log(clusterData)
65+
}
66+
67+
68+
69+
// if (atomCompObj[key].length) {
70+
// for (let i = 0; i < atomCompObj[key].length; i++) {
71+
72+
// if (!memoizeObj[key]) {
73+
// memoizeObj[key] = [];
74+
// if (!clusterData.children && !props[0].atomSelectors[key]) clusterData.children = [];
75+
// clusterData.children.push({ name: key });
76+
// }
77+
78+
79+
// if (!memoizeObj[key].includes(atomCompObj[key][i])) {
80+
// if (!clusterData.children[counter].children)
81+
// clusterData.children[counter].children = [];
82+
// clusterData.children[counter].children.push({
83+
// name: atomCompObj[key][i],
84+
// });
85+
// }
86+
// memoizeObj[key].push(atomCompObj[key][i]);
87+
// }
88+
// }
89+
// counter++;
90+
// }
91+
// console.log(clusterData)
92+
93+
94+
function reorganizedCompObj(props) {
95+
let atomsComponentObj = props[0].atomsComponents;
96+
let reorganizedCompObj = {};
97+
98+
for (const key in atomsComponentObj) {
99+
for (let i = 0; i < atomsComponentObj[key].length; i++) {
100+
if (!reorganizedCompObj[atomsComponentObj[key][i]]) {
101+
reorganizedCompObj[atomsComponentObj[key][i]] = [key];
102+
} else {
103+
reorganizedCompObj[atomsComponentObj[key][i]].push(key);
50104
}
51105
}
52-
counter++;
53106
}
107+
return reorganizedCompObj;
54108
}
55109

56-
function reorganizedObj(props) {
110+
function reorganizedFamObj(props) {
57111
let atomsComponentObj = props[0].atomsComponents;
58-
let reorganizedObj = {};
112+
let reorganizedCompObj = {};
59113

60114
for (const key in atomsComponentObj) {
61115
for (let i = 0; i < atomsComponentObj[key].length; i++) {
62-
if (!reorganizedObj[atomsComponentObj[key][i]]) {
63-
reorganizedObj[atomsComponentObj[key][i]] = [key];
116+
if (!reorganizedCompObj[atomsComponentObj[key][i]]) {
117+
reorganizedCompObj[atomsComponentObj[key][i]] = [key];
64118
} else {
65-
reorganizedObj[atomsComponentObj[key][i]].push(key);
119+
reorganizedCompObj[atomsComponentObj[key][i]].push(key);
66120
}
67121
}
68122
}
69-
return reorganizedObj;
123+
return reorganizedCompObj;
70124
}
71125

72126
function Node({ node }) {

src/app/components/StateRoute.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,8 @@ interface StateRouteProps {
4747

4848
const StateRoute = (props: StateRouteProps) => {
4949
const { snapshot, hierarchy, snapshots, viewIndex } = props;
50-
5150
const isRecoil = snapshot.atomsComponents ? true : false;
5251
const [noRenderData, setNoRenderData] = useState(false);
53-
5452
// component map zoom state
5553
const [{ x, y, k }, setZoomState]: any = useState({
5654
x: 150,

src/backend/linkFiber.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ function createTree(
230230
) {
231231
let getState = currentFiber.memoizedState.next.memoizedState.deps[1].current.getState()
232232
.graphsByVersion;
233-
getState.entries().forEach((value) => {
233+
getState.entries().forEach((value) => {
234234
value[1].nodeDeps.entries().forEach((obj) => {
235235
if (!atomsSelectors[obj[0]]) {
236236
atomsSelectors[obj[0]] = [];

0 commit comments

Comments
 (0)