diff options
-rw-r--r-- | org-roam-ui.el | 6 | ||||
-rw-r--r-- | pages/index.tsx | 8 |
2 files changed, 12 insertions, 2 deletions
diff --git a/org-roam-ui.el b/org-roam-ui.el index 80991ad..fe012f6 100644 --- a/org-roam-ui.el +++ b/org-roam-ui.el @@ -115,9 +115,11 @@ ROWS is the sql result, while COLUMN-NAMES is the columns to use." (setq html-string (org-export-as 'html))) (insert html-string))) -(defservlet* current-node-data text/event-stream () +(defservlet* current-node-id text/event-stream () (insert (format "data: %s\n\n" - org-roam-ui-current-node-id))) + org-roam-ui-current-node-id)) + (httpd-send-header t "text/event-stream" 200 :Access-Control-Allow-Origin "*") + ) (defun org-roam-ui-update () "Track changes within Emacs to update Org-roam UI. 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) => { |