Skip to content

Commit cf24914

Browse files
committed
fix: dedupe raw node choices
1 parent b2fc00b commit cf24914

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/main/frontend/components/property/value.cljs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,9 +674,11 @@
674674
675675
(defn- add-initial-node-choice
676676
[initial-choices new-choice]
677-
(let [node-choice-match? (fn [choice]
678-
(let [choice-value (:value choice)
679-
new-value (:value new-choice)]
677+
(let [choice-node-value (fn [choice]
678+
(or (:value choice) choice))
679+
node-choice-match? (fn [choice]
680+
(let [choice-value (choice-node-value choice)
681+
new-value (choice-node-value new-choice)]
680682
(or
681683
(and (:db/id choice-value) (= (:db/id choice-value) (:db/id new-value)))
682684
(and (:block/uuid choice-value) (= (:block/uuid choice-value) (:block/uuid new-value)))

src/test/frontend/components/property/value_test.cljs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@
8484
(is (= [existing]
8585
(#'property-value/add-initial-node-choice [existing] duplicate)))))
8686

87+
(deftest add-initial-node-choice-dedupes-existing-raw-entity-test
88+
(let [existing {:db/id 100
89+
:block/uuid #uuid "11111111-1111-1111-1111-111111111111"
90+
:block/title "Existing node"}
91+
duplicate {:value {:db/id 100
92+
:block/uuid #uuid "11111111-1111-1111-1111-111111111111"}
93+
:label "Existing node"}]
94+
(is (= [existing]
95+
(#'property-value/add-initial-node-choice [existing] duplicate)))))
96+
8797
(deftest add-initial-node-choice-keeps-distinct-node-with-same-label-test
8898
(let [existing {:value {:db/id 100
8999
:block/uuid #uuid "11111111-1111-1111-1111-111111111111"}

0 commit comments

Comments
 (0)