fix: don't run transact! macro if db requests are not finished yet

pull/10793/head
Tienson Qin 2024-01-16 02:52:38 +08:00
parent 9b344e12f7
commit a3d5fc699d
2 changed files with 11 additions and 8 deletions

View File

@ -66,3 +66,5 @@
(conn/start! repo option)))
(def new-block-id ldb/new-block-id)
(def request-finished? ldb/request-finished?)

View File

@ -17,11 +17,12 @@
(defmacro transact!
[opts & body]
`(let [transact-opts# {:repo (state/get-current-repo)
:conn (db/get-db false)
:unlinked-graph? frontend.modules.outliner.ui/unlinked-graph?
:set-state-fn frontend.modules.outliner.ui/set-state-fn}]
(when-not (:ui/before-editor-cursor @state/state)
(state/set-state! :ui/before-editor-cursor (state/get-current-edit-block-and-position)))
(logseq.outliner.transaction/transact! (assoc ~opts :transact-opts transact-opts#)
~@body)))
`(when (db/request-finished?)
(let [transact-opts# {:repo (state/get-current-repo)
:conn (db/get-db false)
:unlinked-graph? frontend.modules.outliner.ui/unlinked-graph?
:set-state-fn frontend.modules.outliner.ui/set-state-fn}]
(when-not (:ui/before-editor-cursor @state/state)
(state/set-state! :ui/before-editor-cursor (state/get-current-edit-block-and-position)))
(logseq.outliner.transaction/transact! (assoc ~opts :transact-opts transact-opts#)
~@body))))