fix: multiple tags error in graph view

pull/2124/head^2
Tienson Qin 2021-06-07 20:25:57 +08:00
parent 3a8da3262a
commit 825910f34d
1 changed files with 14 additions and 6 deletions

View File

@ -56,7 +56,10 @@
(or (util/uuid-string? id) (or (util/uuid-string? id)
(string/starts-with? id "../assets/") (string/starts-with? id "../assets/")
(= id "..") (= id "..")
(string/starts-with? id "assets/")))) (string/starts-with? id "assets/")
(string/ends-with? id ".gif")
(string/ends-with? id ".jpg")
(string/ends-with? id ".png"))))
(defn- remove-uuids-and-files! (defn- remove-uuids-and-files!
[nodes] [nodes]
@ -80,14 +83,19 @@
(get x :block/original-name (:block/name x))) names)) (get x :block/original-name (:block/name x))) names))
nodes (mapv (fn [node] (assoc node :id (get names (:id node) (:id node)))) nodes) nodes (mapv (fn [node] (assoc node :id (get names (:id node) (:id node)))) nodes)
links (->> links (->>
links
(remove (fn [{:keys [source target]}]
(or (nil? source) (nil? target))))
(mapv (fn [{:keys [source target]}] (mapv (fn [{:keys [source target]}]
(when (and (not (uuid-or-asset? source)) (when (and (not (uuid-or-asset? source))
(not (uuid-or-asset? target))) (not (uuid-or-asset? target)))
{:source (get names source) {:source (get names (string/lower-case source))
:target (get names target)})) :target (get names (string/lower-case target))})))
links) (remove nil?)
(remove nil?)) (remove (fn [{:keys [source target]}]
nodes (remove-uuids-and-files! nodes)] (or (nil? source) (nil? target)))))
nodes (->> (remove-uuids-and-files! nodes)
(util/distinct-by #(string/lower-case (:id %))))]
{:nodes nodes {:nodes nodes
:links links})) :links links}))