@@ -42,7 +42,10 @@ interface selectorsCache {
4242
4343const clusterData : clusterShape = { } ;
4444const selectorsCache :selectorsCache = { } ;
45-
45+ const bothObj = { } ;
46+
47+ console . log ( 'bothObj' , bothObj )
48+
4649let initialFire = false
4750function clusterDataPopulate ( props :StateRouteProps ) {
4851 let atomCompObj = reorganizedCompObj ( props ) ;
@@ -60,10 +63,14 @@ function clusterDataPopulate(props:StateRouteProps) {
6063 let outerobj :outerObjShape = { }
6164 outerobj . name = key
6265 selectorsCache [ key ] = true
66+
67+ if ( ! bothObj [ key ] ) {
68+ bothObj [ key ] = [ ]
69+ }
70+
6371
6472 if ( props [ 0 ] . atomSelectors [ key ] . length ) {
6573 for ( let i = 0 ; i < props [ 0 ] . atomSelectors [ key ] . length ; i ++ ) {
66-
6774 if ( ! outerobj . children ) outerobj . children = [ ]
6875 let innerobj :innerObjShape = { }
6976 innerobj . name = props [ 0 ] . atomSelectors [ key ] [ i ]
@@ -72,8 +79,15 @@ function clusterDataPopulate(props:StateRouteProps) {
7279 //if atoms contain components
7380 if ( atomCompObj [ props [ 0 ] . atomSelectors [ key ] [ i ] ] ) {
7481 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+
7587 if ( ! innerobj . children ) innerobj . children = [ ]
7688 innerobj . children . push ( { name :atomCompObj [ props [ 0 ] . atomSelectors [ key ] [ i ] ] } )
89+ bothObj [ key ] . push ( atomCompObj [ props [ 0 ] . atomSelectors [ key ] [ i ] ] [ 0 ] )
90+
7791 }
7892 }
7993 outerobj . children . push ( innerobj )
@@ -84,6 +98,11 @@ function clusterDataPopulate(props:StateRouteProps) {
8498 if ( atomCompObj [ key ] && atomCompObj [ key ] . length ) {
8599 for ( let i = 0 ; i < atomCompObj [ key ] . length ; i ++ ) {
86100 outerobj . children . push ( { name :atomCompObj [ key ] [ i ] } )
101+
102+ if ( ! bothObj [ key ] ) {
103+ bothObj [ key ] = [ ]
104+ }
105+ bothObj [ key ] . push ( atomCompObj [ key ] [ i ] )
87106 }
88107 }
89108
@@ -95,9 +114,11 @@ function clusterDataPopulate(props:StateRouteProps) {
95114 let outObj :outerObjShape = { } ;
96115 if ( ! selectorsCache [ key ] ) {
97116 outObj . name = key
117+ if ( ! bothObj [ key ] ) bothObj [ key ] = [ ]
98118 for ( let i = 0 ; i < atomCompObj [ key ] . length ; i ++ ) {
99119 if ( ! outObj . children ) outObj . children = [ ]
100120 outObj . children . push ( { name :atomCompObj [ key ] [ i ] } )
121+ bothObj [ key ] . push ( atomCompObj [ key ] [ i ] )
101122 }
102123 clusterData . children . push ( outObj )
103124 }
@@ -123,14 +144,14 @@ function reorganizedCompObj(props) {
123144 return reorganizedCompObj ;
124145}
125146
126- function Node ( { node } ) {
127- const [ dispatch ] = useStoreContext ( ) ;
147+ function Node ( { node, snapshots , dispatch } ) {
148+ // const [dispatch] = useStoreContext();
128149 const selector = node . depth === 1 && node . height === 2
129150 const isRoot = node . depth === 0 ;
130151 const isParent = ! ! node . children ;
131-
152+
132153 if ( isRoot ) return < RootNode node = { node } /> ;
133- if ( selector ) return < SelectorNode node = { node } /> ;
154+ if ( selector ) return < SelectorNode node = { node } snapshots = { snapshots } /> ;
134155
135156 return (
136157 < Group top = { node . y } left = { node . x } >
@@ -140,12 +161,11 @@ function Node({ node }) {
140161 fill = { isParent ? orange : blue }
141162 stroke = { isParent ? orange : blue }
142163 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]))
149169 } }
150170 />
151171 ) }
@@ -165,6 +185,7 @@ function Node({ node }) {
165185}
166186
167187function RootNode ( { node } ) {
188+
168189 const width = 40 ;
169190 const height = 20 ;
170191 const centerX = - width / 2 ;
@@ -198,8 +219,8 @@ function RootNode({ node }) {
198219 ) ;
199220}
200221
201- function SelectorNode ( { node } ) {
202- const [ dispatch ] = useStoreContext ( ) ;
222+ function SelectorNode ( { node, snapshots , dispatch } ) {
223+ // const [dispatch] = useStoreContext();
203224 return (
204225 < Group top = { node . y } left = { node . x } >
205226 { node . depth !== 0 && (
@@ -208,13 +229,11 @@ function SelectorNode({ node }) {
208229 fill = { selectWhite }
209230 stroke = { selectWhite }
210231 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]))
218237 } }
219238 />
220239 ) }
@@ -247,7 +266,7 @@ export default function AtomsRelationship({
247266 margin = defaultMargin ,
248267 snapshots,
249268} ) {
250-
269+ const [ dispatch ] = useStoreContext ( ) ;
251270 if ( ! initialFire ) {
252271 clusterDataPopulate ( snapshots ) ;
253272 }
@@ -282,7 +301,9 @@ export default function AtomsRelationship({
282301 ) ) }
283302 { cluster . descendants ( ) . map ( ( node , i ) => (
284303 < Node key = { `cluster-node-${ i } ` }
285- node = { node } />
304+ node = { node }
305+ snapshots = { snapshots }
306+ dispatch = { dispatch } />
286307 ) ) }
287308 </ Group >
288309 ) }
0 commit comments