Browse Source

fix(watcher): demo graph init watcher event

Andelf 2 years ago
parent
commit
c196d1e026
2 changed files with 7 additions and 2 deletions
  1. 1 0
      src/main/frontend/config.cljs
  2. 6 2
      src/main/frontend/fs/watcher_handler.cljs

+ 1 - 0
src/main/frontend/config.cljs

@@ -358,6 +358,7 @@
   [s]
   (string/replace s local-db-prefix ""))
 
+;; FIXME(andelf): this is not the reverse op of get-repo-dir, should be fixed
 (defn get-local-repo
   [dir]
   (str local-db-prefix dir))

+ 6 - 2
src/main/frontend/fs/watcher_handler.cljs

@@ -55,10 +55,14 @@
   (when dir
     (let [;; 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))
+          repo (cond
+                 global-dir (state/get-current-repo)
+                 ;; FIXME(andelf): hack for demo graph, demo graph does not bind to local directory
+                 (string/starts-with? dir "memory://") "local"
+                 :else (config/get-local-repo dir))
           {:keys [mtime]} stat
           db-content (or (db/get-file repo path) "")]
-      
+
       (when (or content (contains? #{"unlink" "unlinkDir" "addDir"} type))
         (cond
           (and (= "unlinkDir" type) dir)