fix: add pre-configured properties when creating a new db graph

This commit is contained in:
Tienson Qin
2023-08-02 01:49:23 +08:00
parent 791bd90d88
commit 15cb78fbf7
10 changed files with 108 additions and 39 deletions

View File

@@ -804,19 +804,26 @@
[block-id all-properties key add?]
(when-let [block (db/entity [:block/uuid block-id])]
(let [properties (:block/properties block)
query-properties (or (pu/lookup properties :query-properties) "")
query-properties (-> query-properties
(common-handler/safe-read-string "Failed to parse query properties"))
query-properties (pu/lookup properties :query-properties)
repo (state/get-current-repo)
db-based? (config/db-based-graph? repo)
query-properties (if db-based?
query-properties
(some-> query-properties
(common-handler/safe-read-string "Parsing query properties failed")))
query-properties (if (seq query-properties)
query-properties
all-properties)
query-properties (if add?
(distinct (conj query-properties key))
(remove #{key} query-properties))
query-properties (vec query-properties)
repo (state/get-current-repo)]
query-properties (vec query-properties)]
(if (seq query-properties)
(property-handler/set-block-property! repo block-id :query-properties (str query-properties))
(property-handler/set-block-property! repo block-id
:query-properties
(if db-based?
query-properties
(str query-properties)))
(property-handler/remove-block-property! repo block-id :query-properties)))))
(defn set-block-timestamp!