Skip to content

Commit bf3222f

Browse files
committed
(add) Added dispatch logic for onHover for AtomsRelationship map
1 parent f0b4e2e commit bf3222f

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

src/app/components/AtomsRelationship.tsx

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ function Node({ node, snapshots, dispatch, bothObj}) {
150150
const isParent = !!node.children;
151151

152152
if (isRoot) return <RootNode node={node} />;
153-
if (selector) return <SelectorNode node = {node} snapshots = {snapshots} bothObj = {bothObj}/>;
153+
if (selector) return <SelectorNode node = {node} snapshots = {snapshots} bothObj = {bothObj} dispatch = {dispatch}/>;
154154

155155
return (
156156
<Group top={node.y} left={node.x}>
@@ -160,12 +160,9 @@ function Node({ node, snapshots, dispatch, bothObj}) {
160160
fill={isParent ? orange : blue}
161161
stroke={isParent ? orange : blue}
162162
onMouseEnter={()=> {
163-
console.log(bothObj)
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]))
163+
for (let i=0; i<bothObj[node.data.name].length; i++){
164+
dispatch(onHover(snapshots[0].recoilDomNode[bothObj[node.data.name][i]]))
165+
}
169166
}}
170167
/>
171168
)}
@@ -220,7 +217,6 @@ function RootNode({ node }) {
220217
}
221218

222219
function SelectorNode({ node, snapshots, dispatch, bothObj}) {
223-
// const [dispatch] = useStoreContext();
224220
return (
225221
<Group top={node.y} left={node.x}>
226222
{node.depth !== 0 && (
@@ -229,12 +225,9 @@ function SelectorNode({ node, snapshots, dispatch, bothObj}) {
229225
fill={selectWhite}
230226
stroke={selectWhite}
231227
onMouseEnter={()=> {
232-
console.log(bothObj)
233-
console.log(clusterData)
234-
console.log(snapshots[0].recoilDomNode)
235-
console.log(node.data.name)
236-
// console.log(snapshots[0].recoilDomNode[node.data.name])
237-
// dispatch(onHover(snapshots[0].recoilDomNode[node.data.name]))
228+
for (let i=0; i<bothObj[node.data.name].length; i++){
229+
dispatch(onHover(snapshots[0].recoilDomNode[bothObj[node.data.name][i]]))
230+
}
238231
}}
239232
/>
240233
)}
@@ -280,7 +273,8 @@ export default function AtomsRelationship({
280273

281274
let filtered = removeDup(bothObj)
282275

283-
const [dispatch] = useStoreContext();
276+
const [{ tabs, currentTab }, dispatch] = useStoreContext();
277+
284278
if(!initialFire){
285279
clusterDataPopulate(snapshots);
286280
}
@@ -316,7 +310,7 @@ export default function AtomsRelationship({
316310
{cluster.descendants().map((node, i) => (
317311
<Node key={`cluster-node-${i}`}
318312
node={node}
319-
bothObj = {bothObj}
313+
bothObj = {filtered}
320314
snapshots = {snapshots}
321315
dispatch = {dispatch} />
322316
))}

0 commit comments

Comments
 (0)