Browse Source

fix: use debounced git auto commit setting fn

Andelf 1 year ago
parent
commit
095be37cc8
2 changed files with 6 additions and 5 deletions
  1. 2 4
      src/electron/electron/git.cljs
  2. 4 1
      src/electron/electron/handler.cljs

+ 2 - 4
src/electron/electron/git.cljs

@@ -175,7 +175,6 @@
 (defn- auto-commit-tick-fn
   []
   (when (state/git-auto-commit-enabled?)
-    (logger/debug ::auto-commit)
     (add-all-and-commit!)))
 
 (defn configure-auto-commit!
@@ -188,9 +187,8 @@
           millis (if (int? seconds)
                    (* seconds 1000)
                    6000)]
-      (logger/info ::auto-commit-interval seconds)
-      ;; each time we change the auto-commit settings, we will commit the current graph in 5 seconds
-      (js/setTimeout add-all-and-commit! 5000)
+      (logger/info ::set-auto-commit-interval seconds)
+      (js/setTimeout add-all-and-commit! 100)
       (reset! auto-commit-interval (js/setInterval auto-commit-tick-fn millis)))))
 
 (defn before-graph-close-hook!

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

@@ -29,6 +29,7 @@
             [electron.state :as state]
             [electron.utils :as utils]
             [electron.window :as win]
+            [goog.functions :refer [debounce]]
             [logseq.common.graph :as common-graph]
             [promesa.core :as p]))
 
@@ -501,10 +502,12 @@
 (defmethod handle :gitStatus [_ [_]]
   (git/short-status!))
 
+(def debounced-configure-auto-commit! (debounce git/configure-auto-commit! 5000))
 (defmethod handle :setGitAutoCommit []
-  (git/configure-auto-commit!)
+  (debounced-configure-auto-commit!)
   nil)
 
+
 (defmethod handle :installMarketPlugin [_ [_ mft]]
   (plugin/install-or-update! mft))