Skip to content

Commit 70cf508

Browse files
committed
fix(api): adding tag property using api produces empty tag
fixes logseq/db-test#390
1 parent 48fb2b8 commit 70cf508

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

deps/outliner/src/logseq/outliner/property.cljs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -306,16 +306,25 @@
306306

307307
(defn- get-property-value-eid
308308
[db property-id raw-value]
309-
(first
310-
(d/q '[:find [?v ...]
311-
:in $ ?property-id ?raw-value
312-
:where
313-
[?b ?property-id ?v]
314-
(or [?v :block/title ?raw-value]
315-
[?v :logseq.property/value ?raw-value])]
316-
db
317-
property-id
318-
raw-value)))
309+
(if (= property-id :block/tags)
310+
(first
311+
(d/q '[:find [?v ...]
312+
:in $ ?title
313+
:where
314+
[?v :block/title ?title]
315+
[?v :block/tags :logseq.class/Tag]]
316+
db
317+
raw-value))
318+
(first
319+
(d/q '[:find [?v ...]
320+
:in $ ?property-id ?raw-value
321+
:where
322+
[?b ?property-id ?v]
323+
(or [?v :block/title ?raw-value]
324+
[?v :logseq.property/value ?raw-value])]
325+
db
326+
property-id
327+
raw-value))))
319328

320329
(defn- find-or-create-property-value
321330
"Find or create a property value. Only to be used with properties that have ref types"
@@ -491,7 +500,8 @@
491500
[:db/retract (:db/id block) :block/tags :logseq.class/Task]]
492501
{:outliner-op :save-block})
493502

494-
(= (:logseq.property/default-value property) (get block property-id))
503+
(and (:logseq.property/default-value property)
504+
(= (:logseq.property/default-value property) (get block property-id)))
495505
(ldb/transact! conn
496506
[{:db/id (:db/id block)
497507
property-id :logseq.property/empty-placeholder}]

0 commit comments

Comments
 (0)