From 825910f34d1af26a335723aabcc55d483e3ae78c Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Mon, 7 Jun 2021 20:25:57 +0800 Subject: [PATCH] fix: multiple tags error in graph view --- src/main/frontend/handler/graph.cljs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/frontend/handler/graph.cljs b/src/main/frontend/handler/graph.cljs index 8fc6df8e8..12abacd32 100644 --- a/src/main/frontend/handler/graph.cljs +++ b/src/main/frontend/handler/graph.cljs @@ -56,7 +56,10 @@ (or (util/uuid-string? id) (string/starts-with? id "../assets/") (= 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! [nodes] @@ -80,14 +83,19 @@ (get x :block/original-name (:block/name x))) names)) nodes (mapv (fn [node] (assoc node :id (get names (:id node) (:id node)))) nodes) links (->> + links + (remove (fn [{:keys [source target]}] + (or (nil? source) (nil? target)))) (mapv (fn [{:keys [source target]}] (when (and (not (uuid-or-asset? source)) (not (uuid-or-asset? target))) - {:source (get names source) - :target (get names target)})) - links) - (remove nil?)) - nodes (remove-uuids-and-files! nodes)] + {:source (get names (string/lower-case source)) + :target (get names (string/lower-case target))}))) + (remove nil?) + (remove (fn [{:keys [source target]}] + (or (nil? source) (nil? target))))) + nodes (->> (remove-uuids-and-files! nodes) + (util/distinct-by #(string/lower-case (:id %))))] {:nodes nodes :links links}))