Fix global directory watcher not working for multiple windows

Fix also simplifies global config component and generalizes file watcher
to handle any global directory. Also fixed intermittent, annoying "object could not
be cloned" error
This commit is contained in:
Gabriel Horner
2022-09-07 21:42:28 -04:00
committed by Andelf
parent 12b8592f9b
commit 6e3f784626
5 changed files with 113 additions and 82 deletions

View File

@@ -45,10 +45,12 @@
(db/set-file-last-modified-at! repo path mtime)))
(defn handle-changed!
[type {:keys [dir path content stat current-repo-dir] :as payload}]
[type {:keys [dir path content stat global-dir] :as payload}]
(when dir
(let [path (gp-util/path-normalize path)
repo (config/get-local-repo (or current-repo-dir dir))
;; Global directory events don't know their originating repo so we rely
;; on the client to correctly identify it
repo (if global-dir (state/get-current-repo) (config/get-local-repo dir))
pages-metadata-path (config/get-pages-metadata-path)
{:keys [mtime]} stat
db-content (or (db/get-file repo path) "")]