From 1d66292f8f16af75ac878a94a87abf9e56ee38ea Mon Sep 17 00:00:00 2001
From: "Thomas F. K. Jorna" <thomasfkjorna@gmail.com>
Date: Thu, 22 Jul 2021 18:37:41 +0200
Subject: added eventsource node tracking

---
 pages/index.tsx | 8 ++++++++
 1 file changed, 8 insertions(+)

(limited to 'pages/index.tsx')

diff --git a/pages/index.tsx b/pages/index.tsx
index 356f5bb..31cc0ba 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -139,11 +139,19 @@ export function GraphPage() {
   const [physics, setPhysics] = usePersistantState('physics', initialPhysics)
   const [theme, setTheme] = useState(initialTheme)
   const [graphData, setGraphData] = useState<GraphData | null>(null)
+  const [emacsNode, setEmacsNode] = useState<string>('')
 
   const nodeByIdRef = useRef<NodeById>({})
   const linksByNodeIdRef = useRef<LinksByNodeId>({})
 
   useEffect(() => {
+    const trackEmacs = new EventSource('http://127.0.0.1:35901/current-node-id')
+
+    trackEmacs.addEventListener('message', (e) => {
+      setEmacsNode(e.data)
+      console.log(e.data)
+      console.log(emacsNode)
+    })
     fetch('http://localhost:35901/theme')
       .then((res) => res.json())
       .then((emacsTheme) => {
-- 
cgit v1.2.3

