Skip to content

Commit 5b9ea85

Browse files
committed
fix: remove duplicated eavt from tx-report datoms
1 parent 6253dbf commit 5b9ea85

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/main/frontend/worker/pipeline.cljs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,17 @@
341341
fix-page-tags-tx-data
342342
fix-inline-page-tx-data)))
343343

344+
(defn- remove-duplicated-datoms
345+
[datoms]
346+
(let [duplicated-datoms (->> datoms
347+
(group-by (fn [d] (take 4 d))) ; group by '(e a v tx)
348+
(keep (fn [[_eavt same-v-datoms]]
349+
(when (>= (count same-v-datoms) 2)
350+
(butlast same-v-datoms))))
351+
(apply concat)
352+
set)]
353+
(remove duplicated-datoms datoms)))
354+
344355
(defn transact-pipeline
345356
"Compute extra tx-data and block/refs, should ensure it's a pure function and
346357
doesn't call `d/transact!` or `ldb/transact!`."
@@ -373,8 +384,9 @@
373384
replace-tx-report (when (seq block-refs-tx-id-data)
374385
(d/with (:db-after tx-report*) block-refs-tx-id-data))
375386
tx-report' (or replace-tx-report tx-report*)
376-
full-tx-data (concat (:tx-data tx-report*)
377-
(:tx-data replace-tx-report))]
387+
full-tx-data (-> (concat (:tx-data tx-report*)
388+
(:tx-data replace-tx-report))
389+
remove-duplicated-datoms)]
378390
(assoc tx-report'
379391
:tx-data full-tx-data
380392
:tx-meta tx-meta

0 commit comments

Comments
 (0)