mirror of https://github.com/logseq/logseq
fix: undo && redo
:refresh-ui has been removed to ensure batch txs to be transacted to the UI db before refreshing UIenhance/e2e-browser
parent
b5c3757139
commit
b4154c683a
|
@ -4,15 +4,8 @@
|
|||
(defmacro with-batch-tx-mode
|
||||
"1. start batch-tx mode
|
||||
2. run body
|
||||
3. exit batch-tx mode
|
||||
4. refresh-ui"
|
||||
[conn & body]
|
||||
3. exit batch-tx mode"
|
||||
[& body]
|
||||
`(do (frontend.worker.batch-tx/start-batch-tx-mode)
|
||||
~@body
|
||||
(let [txs# (frontend.worker.batch-tx/get-batch-txs)]
|
||||
(frontend.worker.batch-tx/exit-batch-tx-mode)
|
||||
(when (seq txs#)
|
||||
(when-let [affected-keys# (not-empty
|
||||
(frontend.worker.react/get-affected-queries-keys
|
||||
{:db-after @~conn :tx-data txs#}))]
|
||||
(frontend.worker.util/post-message :refresh-ui {:affected-keys affected-keys#}))))))
|
||||
(frontend.worker.batch-tx/exit-batch-tx-mode)))
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
[repo conn tx-report context]
|
||||
(when-not (:pipeline-replace? (:tx-meta tx-report))
|
||||
(let [tx-meta (:tx-meta tx-report)
|
||||
{:keys [from-disk? new-graph? undo? redo?]} tx-meta]
|
||||
{:keys [from-disk? new-graph?]} tx-meta]
|
||||
(if (or from-disk? new-graph?)
|
||||
{:tx-report tx-report}
|
||||
(let [{:keys [pages blocks]} (ds-report/get-blocks-and-pages tx-report)
|
||||
|
@ -88,24 +88,23 @@
|
|||
(when (d/entity @conn page-id)
|
||||
(file/sync-to-file repo page-id tx-meta)))))
|
||||
deleted-block-uuids (set (outliner-pipeline/filter-deleted-blocks (:tx-data tx-report)))
|
||||
replace-tx (when-not (or undo? redo?)
|
||||
(concat
|
||||
replace-tx (concat
|
||||
;; block path refs
|
||||
(set (compute-block-path-refs-tx tx-report blocks))
|
||||
(set (compute-block-path-refs-tx tx-report blocks))
|
||||
|
||||
;; delete empty property parent block
|
||||
(when (seq deleted-block-uuids)
|
||||
(delete-property-parent-block-if-empty tx-report deleted-block-uuids))
|
||||
(when (seq deleted-block-uuids)
|
||||
(delete-property-parent-block-if-empty tx-report deleted-block-uuids))
|
||||
|
||||
;; update block/tx-id
|
||||
(let [updated-blocks (remove (fn [b] (contains? (set deleted-block-uuids) (:block/uuid b))) blocks)
|
||||
tx-id (get-in tx-report [:tempids :db/current-tx])]
|
||||
(->>
|
||||
(map (fn [b]
|
||||
(when-let [db-id (:db/id b)]
|
||||
{:db/id db-id
|
||||
:block/tx-id tx-id})) updated-blocks)
|
||||
(remove nil?)))))
|
||||
(let [updated-blocks (remove (fn [b] (contains? (set deleted-block-uuids) (:block/uuid b))) blocks)
|
||||
tx-id (get-in tx-report [:tempids :db/current-tx])]
|
||||
(->>
|
||||
(map (fn [b]
|
||||
(when-let [db-id (:db/id b)]
|
||||
{:db/id db-id
|
||||
:block/tx-id tx-id})) updated-blocks)
|
||||
(remove nil?))))
|
||||
tx-report' (or
|
||||
(when (seq replace-tx)
|
||||
;; TODO: remove this since transact! is really slow
|
||||
|
@ -115,13 +114,17 @@
|
|||
(d/store @conn)
|
||||
tx-report))
|
||||
fix-tx-data (validate-and-fix-db! repo conn tx-report context)
|
||||
full-tx-data (concat (:tx-data tx-report) fix-tx-data (:tx-data tx-report'))
|
||||
batch-processing? (batch-tx/tx-batch-processing?)
|
||||
batch-tx-data (batch-tx/get-batch-txs)
|
||||
full-tx-data (concat (:tx-data tx-report)
|
||||
fix-tx-data
|
||||
(:tx-data tx-report')
|
||||
(when (and (not batch-processing?) (seq batch-tx-data))
|
||||
batch-tx-data))
|
||||
final-tx-report (assoc tx-report'
|
||||
:tx-data full-tx-data
|
||||
:db-before (:db-before tx-report))
|
||||
batch-processing? (batch-tx/tx-batch-processing?)
|
||||
affected-query-keys (when-not (or (:importing? context)
|
||||
batch-processing?)
|
||||
affected-query-keys (when-not (:importing? context)
|
||||
(worker-react/get-affected-queries-keys final-tx-report))]
|
||||
(when batch-processing?
|
||||
(batch-tx/conj-batch-txs! full-tx-data))
|
||||
|
|
Loading…
Reference in New Issue