Browse Source

fix: close the existing watcher when adding new graph

Also, don't create today's journal file during parsing
Tienson Qin 4 năm trước cách đây
mục cha
commit
7491857460

+ 1 - 0
src/electron/electron/handler.cljs

@@ -195,6 +195,7 @@
   (search/ensure-search-dir!))
 
 (defmethod handle :addDirWatcher [window [_ dir]]
+  (watcher/close-watcher!)
   (when dir
     (watcher/watch-dir! window dir)))
 

+ 1 - 1
src/main/frontend/fs/watcher_handler.cljs

@@ -45,7 +45,7 @@
 
           (and (= "change" type)
                (not (db/file-exists? repo path)))
-          (js/console.warn "Can't get file in the db: " path)
+          (js/console.error "Can't get file in the db: " path)
 
           (and (= "change" type)
                (not= (string/trim content) (string/trim db-content))

+ 1 - 1
src/main/frontend/handler.cljs

@@ -53,7 +53,7 @@
         f (fn []
             (let [repo (state/get-current-repo)]
               (when-not (state/nfs-refreshing?)
-               ;; Don't create the journal file until user writes something
+                ;; Don't create the journal file until user writes something
                 (page-handler/create-today-journal!))
 
               (when (and (state/input-idle? repo)

+ 1 - 1
src/main/frontend/handler/notification.cljs

@@ -23,7 +23,7 @@
                                                      uid {:content content
                                                           :status status}))
 
-     (when clear?
+     (when (and clear? (not= status :error))
        (js/setTimeout #(clear! uid) 1500))
 
      uid)))

+ 2 - 1
src/main/frontend/handler/page.cljs

@@ -696,7 +696,8 @@
 (defn create-today-journal!
   []
   (when-let [repo (state/get-current-repo)]
-    (when (state/enable-journals? repo)
+    (when (and (state/enable-journals? repo)
+               (not (:repo/loading-files? @state/state)))
       (state/set-today! (date/today))
       (when (or (db/cloned? repo)
                 (or (config/local-db? repo)

+ 5 - 3
src/main/frontend/handler/route.cljs

@@ -20,9 +20,11 @@
     (route-fn to path-params query-params)))
 
 (defn redirect-to-home!
-  []
-  (state/pub-event! [:redirect-to-home])
-  (redirect! {:to :home}))
+  ([]
+   (redirect-to-home! true))
+  ([pub-event?]
+   (when pub-event? (state/pub-event! [:redirect-to-home]))
+   (redirect! {:to :home})))
 
 (defn redirect-to-page!
   ([page-name]

+ 1 - 1
src/main/frontend/handler/web/nfs.cljs

@@ -129,7 +129,7 @@
                                      (swap! path-handles assoc path handle))))
              _ (state/set-loading-files! true)
              _ (when-not (state/home?)
-                 (route-handler/redirect-to-home!))
+                 (route-handler/redirect-to-home! false))
              root-handle (first result)
              dir-name (if nfs?
                         (gobj/get root-handle "name")

+ 3 - 2
src/main/frontend/modules/outliner/file.cljs

@@ -37,8 +37,9 @@
         (try (do-write-file! page-db-id)
              (catch js/Error e
                (notification/show!
-                "Write file failed, please copy the changes to other editors in case of losing data."
-                [:div "Error: " (str (gobj/get e "stack"))]
+                [:div
+                 [:p "Write file failed, please copy the changes to other editors in case of losing data."]
+                 "Error: " (str (gobj/get e "stack"))]
                 :error)
                (log/error :file/write-file-error {:error e})))))))