fix(rtc): tx-meta only works on batch-tx/with-batch-tx-mode now(?)

experiment/tanstack-table
rcmerci 2024-05-21 12:33:34 +08:00
parent 685b78e2a0
commit 05b582e91f
3 changed files with 12 additions and 12 deletions

View File

@ -160,7 +160,7 @@
(case (:type event)
:remote-update
(r.remote-update/apply-remote-update repo conn date-formatter event add-log-fn)
;; TODO: add case: fetch earlier remote data
:local-update-check
(m/? (r.client/new-task--push-local-ops
repo conn graph-uuid date-formatter

View File

@ -178,7 +178,8 @@
(defn- new-task--transact-remote-all-blocks
[all-blocks repo graph-uuid]
(let [{:keys [t blocks]} all-blocks
blocks (normalized-remote-blocks-coercer blocks)
blocks (worker-util/profile :normalize-remote-blocks
(normalized-remote-blocks-coercer blocks))
blocks* (remote-block-index->block-order blocks)
blocks-with-page-id (fill-block-fields blocks*)
tx-data (concat blocks-with-page-id

View File

@ -356,13 +356,12 @@
(seq remote-only) (concat (map (fn [v] [:db/add e k v]) remote-only)))))))
(defn- diff-block-map->tx-data
[db local-block-map remote-block-map]
(let [e (:db/id local-block-map)]
(mapcat
(fn [[k local-v]]
(let [remote-v (get remote-block-map k)]
(seq (diff-block-kv->tx-data db (d/schema db) e k local-v remote-v))))
local-block-map)))
[db e local-block-map remote-block-map]
(mapcat
(fn [[k local-v]]
(let [remote-v (get remote-block-map k)]
(seq (diff-block-kv->tx-data db (d/schema db) e k local-v remote-v))))
local-block-map))
(defn- remote-op-value->tx-data
[conn block-uuid op-value]
@ -384,8 +383,8 @@
v*)
;; else
v)])))
(into {:db/id (:db/id ent)}))]
(diff-block-map->tx-data db local-block-map op-value)))
(into {}))]
(diff-block-map->tx-data db (:db/id ent) local-block-map op-value)))
(defn- update-block-attrs
[repo conn block-uuid {:keys [parents properties _content] :as op-value}]
@ -482,7 +481,7 @@
update-page-ops (vals update-page-ops-map)
remove-page-ops (vals remove-page-ops-map)]
(batch-tx/with-batch-tx-mode conn {:rtc-tx? true}
(batch-tx/with-batch-tx-mode conn {:rtc-tx? true :persist-op? false :gen-undo-ops? false}
(js/console.groupCollapsed "rtc/apply-remote-ops-log")
(worker-util/profile :apply-remote-update-page-ops (apply-remote-update-page-ops repo conn update-page-ops))
(worker-util/profile :apply-remote-remove-ops (apply-remote-remove-ops repo conn date-formatter remove-ops))