@@ -42,7 +42,10 @@ interface selectorsCache {
42
42
43
43
const clusterData : clusterShape = { } ;
44
44
const selectorsCache :selectorsCache = { } ;
45
-
45
+ const bothObj = { } ;
46
+
47
+ console . log ( 'bothObj' , bothObj )
48
+
46
49
let initialFire = false
47
50
function clusterDataPopulate ( props :StateRouteProps ) {
48
51
let atomCompObj = reorganizedCompObj ( props ) ;
@@ -60,10 +63,14 @@ function clusterDataPopulate(props:StateRouteProps) {
60
63
let outerobj :outerObjShape = { }
61
64
outerobj . name = key
62
65
selectorsCache [ key ] = true
66
+
67
+ if ( ! bothObj [ key ] ) {
68
+ bothObj [ key ] = [ ]
69
+ }
70
+
63
71
64
72
if ( props [ 0 ] . atomSelectors [ key ] . length ) {
65
73
for ( let i = 0 ; i < props [ 0 ] . atomSelectors [ key ] . length ; i ++ ) {
66
-
67
74
if ( ! outerobj . children ) outerobj . children = [ ]
68
75
let innerobj :innerObjShape = { }
69
76
innerobj . name = props [ 0 ] . atomSelectors [ key ] [ i ]
@@ -72,8 +79,15 @@ function clusterDataPopulate(props:StateRouteProps) {
72
79
//if atoms contain components
73
80
if ( atomCompObj [ props [ 0 ] . atomSelectors [ key ] [ i ] ] ) {
74
81
for ( let j = 0 ; j < atomCompObj [ props [ 0 ] . atomSelectors [ key ] [ i ] ] . length ; j ++ ) {
82
+ if ( ! bothObj [ props [ 0 ] . atomSelectors [ key ] [ i ] ] ) {
83
+ bothObj [ props [ 0 ] . atomSelectors [ key ] [ i ] ] = [ ]
84
+ }
85
+ bothObj [ props [ 0 ] . atomSelectors [ key ] [ i ] ] . push ( atomCompObj [ props [ 0 ] . atomSelectors [ key ] [ i ] ] [ 0 ] )
86
+
75
87
if ( ! innerobj . children ) innerobj . children = [ ]
76
88
innerobj . children . push ( { name :atomCompObj [ props [ 0 ] . atomSelectors [ key ] [ i ] ] } )
89
+ bothObj [ key ] . push ( atomCompObj [ props [ 0 ] . atomSelectors [ key ] [ i ] ] [ 0 ] )
90
+
77
91
}
78
92
}
79
93
outerobj . children . push ( innerobj )
@@ -84,6 +98,11 @@ function clusterDataPopulate(props:StateRouteProps) {
84
98
if ( atomCompObj [ key ] && atomCompObj [ key ] . length ) {
85
99
for ( let i = 0 ; i < atomCompObj [ key ] . length ; i ++ ) {
86
100
outerobj . children . push ( { name :atomCompObj [ key ] [ i ] } )
101
+
102
+ if ( ! bothObj [ key ] ) {
103
+ bothObj [ key ] = [ ]
104
+ }
105
+ bothObj [ key ] . push ( atomCompObj [ key ] [ i ] )
87
106
}
88
107
}
89
108
@@ -95,9 +114,11 @@ function clusterDataPopulate(props:StateRouteProps) {
95
114
let outObj :outerObjShape = { } ;
96
115
if ( ! selectorsCache [ key ] ) {
97
116
outObj . name = key
117
+ if ( ! bothObj [ key ] ) bothObj [ key ] = [ ]
98
118
for ( let i = 0 ; i < atomCompObj [ key ] . length ; i ++ ) {
99
119
if ( ! outObj . children ) outObj . children = [ ]
100
120
outObj . children . push ( { name :atomCompObj [ key ] [ i ] } )
121
+ bothObj [ key ] . push ( atomCompObj [ key ] [ i ] )
101
122
}
102
123
clusterData . children . push ( outObj )
103
124
}
@@ -123,14 +144,14 @@ function reorganizedCompObj(props) {
123
144
return reorganizedCompObj ;
124
145
}
125
146
126
- function Node ( { node } ) {
127
- const [ dispatch ] = useStoreContext ( ) ;
147
+ function Node ( { node, snapshots , dispatch } ) {
148
+ // const [dispatch] = useStoreContext();
128
149
const selector = node . depth === 1 && node . height === 2
129
150
const isRoot = node . depth === 0 ;
130
151
const isParent = ! ! node . children ;
131
-
152
+
132
153
if ( isRoot ) return < RootNode node = { node } /> ;
133
- if ( selector ) return < SelectorNode node = { node } /> ;
154
+ if ( selector ) return < SelectorNode node = { node } snapshots = { snapshots } /> ;
134
155
135
156
return (
136
157
< Group top = { node . y } left = { node . x } >
@@ -140,12 +161,11 @@ function Node({ node }) {
140
161
fill = { isParent ? orange : blue }
141
162
stroke = { isParent ? orange : blue }
142
163
onMouseEnter = { ( ) => {
143
- console . log ( 'hi' )
144
- // if(Object.keys(node.data.recoilDomNode).length > 0){
145
- // dispatch(onHover(node.data.recoilDomNode[node.data.name]))
146
- // } else {
147
- // dispatch(onHover(node.data.rtid))
148
- // }
164
+ console . log ( clusterData )
165
+ console . log ( snapshots [ 0 ] . recoilDomNode )
166
+ console . log ( node . data . name )
167
+ // console.log(snapshots[0].recoilDomNode[node.data.name])
168
+ // dispatch(onHover(snapshots[0].recoilDomNode[node.data.name]))
149
169
} }
150
170
/>
151
171
) }
@@ -165,6 +185,7 @@ function Node({ node }) {
165
185
}
166
186
167
187
function RootNode ( { node } ) {
188
+
168
189
const width = 40 ;
169
190
const height = 20 ;
170
191
const centerX = - width / 2 ;
@@ -198,8 +219,8 @@ function RootNode({ node }) {
198
219
) ;
199
220
}
200
221
201
- function SelectorNode ( { node } ) {
202
- const [ dispatch ] = useStoreContext ( ) ;
222
+ function SelectorNode ( { node, snapshots , dispatch } ) {
223
+ // const [dispatch] = useStoreContext();
203
224
return (
204
225
< Group top = { node . y } left = { node . x } >
205
226
{ node . depth !== 0 && (
@@ -208,13 +229,11 @@ function SelectorNode({ node }) {
208
229
fill = { selectWhite }
209
230
stroke = { selectWhite }
210
231
onMouseEnter = { ( ) => {
211
-
212
- console . log ( 'hi' )
213
- // if(Object.keys(node.data.recoilDomNode).length > 0){
214
- // dispatch(onHover(node.data.recoilDomNode[node.data.name]))
215
- // } else {
216
- // dispatch(onHover(node.data.rtid))
217
- // }
232
+ console . log ( clusterData )
233
+ console . log ( snapshots [ 0 ] . recoilDomNode )
234
+ console . log ( node . data . name )
235
+ // console.log(snapshots[0].recoilDomNode[node.data.name])
236
+ // dispatch(onHover(snapshots[0].recoilDomNode[node.data.name]))
218
237
} }
219
238
/>
220
239
) }
@@ -247,7 +266,7 @@ export default function AtomsRelationship({
247
266
margin = defaultMargin ,
248
267
snapshots,
249
268
} ) {
250
-
269
+ const [ dispatch ] = useStoreContext ( ) ;
251
270
if ( ! initialFire ) {
252
271
clusterDataPopulate ( snapshots ) ;
253
272
}
@@ -282,7 +301,9 @@ export default function AtomsRelationship({
282
301
) ) }
283
302
{ cluster . descendants ( ) . map ( ( node , i ) => (
284
303
< Node key = { `cluster-node-${ i } ` }
285
- node = { node } />
304
+ node = { node }
305
+ snapshots = { snapshots }
306
+ dispatch = { dispatch } />
286
307
) ) }
287
308
</ Group >
288
309
) }
0 commit comments