fix: fix order should be after rebase ops

This commit is contained in:
Tienson Qin
2026-04-07 02:26:17 +08:00
parent 8f2e2db7c6
commit 8aae83ae70
4 changed files with 8 additions and 15 deletions

View File

@@ -305,7 +305,6 @@
[conn {:keys [tx outliner-op]}]
(let [tx-data (->> (protocol/transit->tx tx)
(sanitize-tx @conn outliner-op))]
(prn :debug :entity (:block/parent (d/entity @conn [:block/uuid #uuid "69d38949-1f23-4e1c-b7d9-861c16cfdb2c"])))
(when (seq tx-data)
(ldb/transact! conn tx-data (cond-> {:op :apply-client-tx}
outliner-op (assoc :outliner-op outliner-op))))))

View File

@@ -254,7 +254,6 @@
(let [batch-tx-data @*tx-data
_ (reset! *tx-data nil)
_ (prn :debug :batch-tx-data batch-tx-data)
tx-report {:db-before db-before
:db-after @conn
:tx-meta tx-meta

View File

@@ -460,7 +460,6 @@
block' (if (de/entity? block)
block
(merge entity block))]
(prn :debug :block block')
(otree/-save block' *txs-state db opts)
{:tx-data @*txs-state}))))
@@ -1093,8 +1092,8 @@
(ldb/transact! (first args) (:tx-data result) tx-meta)))
result)
(catch :default e
(js/console.error e)
(when-not (= "not-allowed-move-block-page" (ex-message e))
(js/console.error e)
(throw e)))))
(let [f (fn [conn block opts]

View File

@@ -527,10 +527,8 @@
(defn reverse-local-txs!
[conn local-txs]
(prn :debug :local-txs local-txs)
(doall
(->> local-txs
(remove (fn [tx] (= :fix (:outliner-op tx))))
reverse
(map-indexed
(fn [index local-tx]
@@ -655,7 +653,6 @@
db @conn]
(when-not (and target-block (seq blocks))
(invalid-rebase-op! op {:args args}))
(prn :debug :insert-blocks :target-block target-block)
(outliner-core/insert-blocks! conn
(mapv #(op-construct/rewrite-block-title-with-retracted-refs db %) blocks)
target-block
@@ -866,7 +863,6 @@
(fn [conn]
(if (= [[:transact nil]] outliner-ops)
(when-let [tx-data (seq (:tx local-tx))]
(prn :debug :transact :tx-data tx-data)
(ldb/transact! conn tx-data {:outliner-op :transact}))
(do
;; (precreate-missing-save-blocks! conn outliner-ops)
@@ -911,10 +907,10 @@
(when (and (= :rebase (:outliner-op tx-meta))
(seq tx-data))
(swap! *rebase-tx-reports conj tx-report)))})]
(fix-tx! conn tx-report {:outliner-op :fix}))
(doseq [tx-report @*rebase-tx-reports]
(handle-local-tx! repo tx-report))
(doseq [tx-report @*rebase-tx-reports]
(handle-local-tx! repo tx-report))
(fix-tx! conn tx-report {:outliner-op :fix}))
(remove-pending-txs! repo (map :tx-id local-txs))
@@ -993,10 +989,10 @@
[repo {:keys [tx-data db-after db-before tx-meta] :as tx-report}]
(let [normalized (normalize-tx-data db-after db-before tx-data)
reversed-datoms (reverse-tx-data db-before db-after tx-data)]
(prn :debug :enqueue-local-tx :tx-data)
(cljs.pprint/pprint tx-data)
(prn :debug :enqueue-local-tx :normalized)
(cljs.pprint/pprint normalized)
;; (prn :debug :enqueue-local-tx :tx-data)
;; (cljs.pprint/pprint tx-data)
;; (prn :debug :enqueue-local-tx :normalized)
;; (cljs.pprint/pprint normalized)
(when (and (= (:outliner-op tx-meta) :insert-blocks)
(not (:undo? tx-meta))
(not (some (fn [x]