refactor: DRY

This commit is contained in:
Tienson Qin
2020-11-03 15:57:48 +08:00
parent b6ad2aa7da
commit 4da72149ee
3 changed files with 10 additions and 10 deletions

View File

@@ -546,15 +546,13 @@
(when (or (seq retract-refs) pre-block?)
(ui-handler/re-render-root!))
(when (state/git-auto-push?)
(repo-handler/push repo nil)))
(repo-handler/push-if-auto-enabled! repo))
:else
nil))
(seq (state/get-changed-files))
(when (state/git-auto-push?)
(repo-handler/push repo nil))
(repo-handler/push-if-auto-enabled! repo)
:else
nil))))
@@ -1016,8 +1014,7 @@
(route-handler/redirect! {:to :page
:path-params {:name (:page/name page)}})
(ui-handler/re-render-root!))
(when (state/git-auto-push?)
(repo-handler/push repo nil))))))
(repo-handler/push-if-auto-enabled! repo)))))
(defn remove-block-property!
[block-id key]

View File

@@ -257,8 +257,7 @@
file-path)
nil)]
(common-handler/check-changed-files-status)
(when (state/git-auto-push?)
(repo-handler/push repo nil)))
(repo-handler/push-if-auto-enabled! repo))
(p/catch (fn [err]
(prn "error: " err))))))
@@ -304,8 +303,7 @@
(notification/show! "Page renamed successfully!" :success)
(when (state/git-auto-push?)
(repo-handler/push repo nil))
(repo-handler/push-if-auto-enabled! repo)
(ui-handler/re-render-root!)))))

View File

@@ -437,6 +437,11 @@
(println "Git push error: ")
(js/console.dir error)))))))
(defn push-if-auto-enabled!
[repo]
(when (state/git-auto-push?)
(push repo nil)))
(defn pull-current-repo
[]
(when-let [repo (state/get-current-repo)]