diff options
author | Thomas F. K. Jorna <[email protected]> | 2021-07-29 11:14:23 +0200 |
---|---|---|
committer | Thomas F. K. Jorna <[email protected]> | 2021-07-29 11:14:23 +0200 |
commit | 1541dde979d201860f7f43e369f050d4ece00574 (patch) | |
tree | 7e98cd89e15a31ed11529c68f792c93208bab80a /org-roam-ui.el | |
parent | c1ed467b2649bf2c99fea762efcc6684893da6d9 (diff) |
added websocket checks and 3d labels
Diffstat (limited to 'org-roam-ui.el')
-rw-r--r-- | org-roam-ui.el | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/org-roam-ui.el b/org-roam-ui.el index 8a3a5b3..f9eb8dc 100644 --- a/org-roam-ui.el +++ b/org-roam-ui.el @@ -105,13 +105,15 @@ This serves the web-build and API over HTTP." (websocket-server 35903 :host 'local - :on-open (lambda (ws) (progn (setq oru-ws ws) (org-roam-ui--send-graphdata) (org-roam-ui-sync-theme--advice) (message "Connection established with org-roam-ui"))) + :on-open (lambda (ws) (progn (setq oru-ws ws) (org-roam-ui--send-graphdata) (org-roam-ui-sync-theme--advice) (message "Connection established with org-roam-ui") + (add-hook 'post-command-hook #'org-roam-ui--update-current-node) + )) :on-close (lambda (_websocket) (setq oru-ws nil) (message "Connection with org-roam-ui closed succesfully.")))) (if (boundp 'counsel-load-theme) (advice-add 'counsel-load-theme :after #'org-roam-ui-sync-theme--advice) (advice-add 'load-theme :after #'org-roam-ui-sync-theme-manually)) - (add-hook 'post-command-hook #'org-roam-ui--update-current-node) - (add-hook 'post-command-hook #'org-roam-ui-update)) + (add-hook 'post-command-hook #'org-roam-ui--update-current-node)) + ;(add-hook 'post-command-hook #'org-roam-ui-update)) (t (progn (remove-hook 'post-command-hook #'org-roam-ui-update) @@ -135,11 +137,13 @@ This serves the web-build and API over HTTP." (websocket-send-text oru-ws (json-encode `((type . "graphdata") (data . ,response)))))) (defun org-roam-ui--update-current-node () + (when (websocket-openp oru-ws) (let* ((node (org-roam-id-at-point))) (unless (string-match-p (regexp-quote "Minibuf") (buffer-name (current-buffer))) (unless (string= org-roam-ui--ws-current-node node) (setq org-roam-ui--ws-current-node node) (websocket-send-text oru-ws (json-encode `((type . "command") (data . ((commandName . "follow") (id . ,node)))))))))) +) (defun org-roam-ui-show-node () "Open the current org-roam node in org-roam-ui." |