enhance(rtc): don't generate update-op if only :block/updated-at changed

This commit is contained in:
rcmerci
2025-01-10 13:26:15 +08:00
parent b8c569f1c4
commit 72b736abd4

View File

@@ -64,6 +64,10 @@
add?->v->t))
a->add?->v->t))
(defn- redundant-update-op-av-coll?
[av-coll]
(every? (fn [av] (keyword-identical? :block/updated-at (first av))) av-coll))
(defn- max-t
[a->add?->v->t]
(apply max (mapcat vals (mapcat vals (vals a->add?->v->t)))))
@@ -112,8 +116,9 @@
(and (ldb/page? entity) add-block-title))
(conj [:update-page (or t2 t3) {:block-uuid block-uuid}]))
update-op (when-let [av-coll (not-empty (update-op-av-coll db-before db-after a->add?->v->t*))]
(let [t (max-t a->add?->v->t*)]
[:update t {:block-uuid block-uuid :av-coll av-coll}]))]
(when-not (redundant-update-op-av-coll? av-coll)
(let [t (max-t a->add?->v->t*)]
[:update t {:block-uuid block-uuid :av-coll av-coll}])))]
(cond-> ops update-op (conj update-op))))))
(defn- generate-rtc-ops