Browse Source

fix: empty transact to notify batch-tx exit

rcmerci 1 year ago
parent
commit
03246325b3

+ 1 - 0
src/main/frontend/worker/batch_tx.clj

@@ -13,4 +13,5 @@
        ~@body
        (when (seq ~additional-tx)
          (logseq.db/transact! ~conn ~additional-tx {}))
+       (datascript.core/transact! ~conn [] {:batch-tx/exit? true})
        (frontend.worker.batch-tx/exit-batch-txs-mode!))))

+ 4 - 5
src/main/frontend/worker/db_listener.cljs

@@ -68,10 +68,9 @@
     (d/unlisten! conn ::listen-db-changes!)
     (d/listen! conn ::listen-db-changes!
                (fn [{:keys [tx-data _db-before _db-after tx-meta] :as tx-report}]
-                 (let [pipeline-replace? (:pipeline-replace? tx-meta)
-                       batch-processing? (some? (batch-tx/get-batch-db-before))]
+                 (let [pipeline-replace? (:pipeline-replace? tx-meta)]
                    (when-not pipeline-replace?
-                     (if batch-processing?
+                     (if-not (:batch-tx/exit? tx-meta)
                        (batch-tx/conj-batch-txs! tx-data)
                        (let [;; exiting-batch-mode? (> (:batch-tx/counter (d/entity db-before :logseq.kv/tx-batch-counter)) 0)
                              db-before (batch-tx/get-batch-db-before)
@@ -79,9 +78,9 @@
 
                              ;;   (:db-before tx-report))
 
-                             tx-data (batch-tx/get-batch-txs);; (if exiting-batch-mode?
+                             tx-data (batch-tx/get-batch-txs) ;; (if exiting-batch-mode?
 
-                                       ;; (concat (:tx-data tx-report) tx-data))
+                             ;; (concat (:tx-data tx-report) tx-data))
                              tx-report (assoc tx-report
                                               :db-before db-before
                                               :tx-data tx-data)