diff --git a/web/src/components/dashboard/NetworkMap.tsx b/web/src/components/dashboard/NetworkMap.tsx index 6bfa80f..d4d6938 100644 --- a/web/src/components/dashboard/NetworkMap.tsx +++ b/web/src/components/dashboard/NetworkMap.tsx @@ -37,12 +37,7 @@ export const NetworkMap = React.forwardRef<{ resetAutoZoom: () => void }, Networ // Get nodes data from the store const { nodes, gateways } = useAppSelector((state) => state.aggregator); - // Get the latest packet to detect when nodes receive packets - const latestPacket = useAppSelector((state) => - state.packets.packets.length > 0 ? state.packets.packets[0] : null - ); - - // Expose the resetAutoZoom function via ref + // Expose the resetAutoZoom function via ref React.useImperativeHandle(ref, () => ({ resetAutoZoom: () => { resetAutoZoom(); @@ -237,83 +232,6 @@ export const NetworkMap = React.forwardRef<{ resetAutoZoom: () => void }, Networ } }, [autoZoomEnabled, onAutoZoomChange]); - // Effect to detect when a node receives a packet and trigger animation - useEffect(() => { - if (latestPacket && latestPacket.data.from !== undefined) { - const nodeId = latestPacket.data.from; - const key = `node-${nodeId}`; - - // If we have this node on the map, animate it - if (markersRef.current[key]) { - animateNodeMarker(nodeId); - } - } - }, [latestPacket]); - - // Function to animate a node marker when it receives a packet - function animateNodeMarker(nodeId: number): void { - const key = `node-${nodeId}`; - const marker = markersRef.current[key]; - const node = nodesWithPosition.find(n => n.id === nodeId); - - if (!marker || !node) return; - - // Clear any existing animation for this node - if (animatingNodesRef.current[key]) { - clearTimeout(animatingNodesRef.current[key]); - } - - // Get the animated style - const iconStyle = getMarkerIcon(node, true); - - // Create updated content for the marker with animation style - const markerContent = document.createElement('div'); - markerContent.innerHTML = ` - - `; - - // Set cursor style - markerContent.style.cursor = 'pointer'; - - // Update the marker content with animated style - marker.content = markerContent; - - // Reset after a delay - animatingNodesRef.current[key] = window.setTimeout(() => { - // Reset to non-animated style - const normalStyle = getMarkerIcon(node, false); - - const normalContent = document.createElement('div'); - normalContent.innerHTML = ` - - `; - - normalContent.style.cursor = 'pointer'; - marker.content = normalContent; - - delete animatingNodesRef.current[key]; - }, 1000); // 1 second animation - } // Cleanup on unmount useEffect(() => { @@ -513,7 +431,7 @@ export const NetworkMap = React.forwardRef<{ resetAutoZoom: () => void }, Networ const statusDotColor = colors.fill; const infoContent = ` -