Преглед изворни кода

fix: non-page block references with icon missing icon itself

fixed https://github.com/logseq/db-test/issues/475
Tienson Qin пре 3 месеци
родитељ
комит
3a6970567a
2 измењених фајлова са 21 додато и 26 уклоњено
  1. 1 2
      src/main/frontend/components/block.cljs
  2. 20 24
      src/main/frontend/components/icon.cljs

+ 1 - 2
src/main/frontend/components/block.cljs

@@ -776,8 +776,7 @@
        (let [own-icon (get page-entity (pu/get-pid :logseq.property/icon))
              emoji? (and (map? own-icon) (= (:type own-icon) :emoji))]
          (when-let [icon (icon-component/get-node-icon-cp page-entity {:color? true
-                                                                       :not-text-or-page? true
-                                                                       :own-icon? true})]
+                                                                       :not-text-or-page? true})]
            [:span {:class (str "icon-emoji-wrap " (when emoji? "as-emoji"))}
             icon])))
 

+ 20 - 24
src/main/frontend/components/icon.cljs

@@ -46,41 +46,37 @@
 
 (defn get-node-icon
   [node-entity]
-  (let [first-tag-icon (some :logseq.property/icon (sort-by :db/id (:block/tags node-entity)))]
-    (or (get node-entity (pu/get-pid :logseq.property/icon))
-        (let [asset-type (:logseq.property.asset/type node-entity)]
-          (cond
-            (some? first-tag-icon)
-            first-tag-icon
-            (ldb/class? node-entity)
-            "hash"
-            (ldb/property? node-entity)
-            "letter-p"
-            (ldb/whiteboard? node-entity)
-            "writing"
-            (ldb/page? node-entity)
-            "file"
-            (= asset-type "pdf")
-            "book"
-            :else
-            "letter-n")))))
+  (or (get node-entity (pu/get-pid :logseq.property/icon))
+      (let [asset-type (:logseq.property.asset/type node-entity)
+            first-tag-icon (some :logseq.property/icon (sort-by :db/id (:block/tags node-entity)))]
+        (cond
+          (some? first-tag-icon)
+          first-tag-icon
+          (ldb/class? node-entity)
+          "hash"
+          (ldb/property? node-entity)
+          "letter-p"
+          (ldb/whiteboard? node-entity)
+          "writing"
+          (ldb/page? node-entity)
+          "file"
+          (= asset-type "pdf")
+          "book"
+          :else
+          "letter-n"))))
 
 (defn get-node-icon-cp
   [node-entity opts]
   (let [opts' (merge {:size 14} opts)
-        node-icon* (cond
-                     (:own-icon? opts)
-                     (get node-entity (pu/get-pid :logseq.property/icon))
-                     (:link? opts)
+        node-icon* (if (:link? opts)
                      "arrow-narrow-right"
-                     :else
                      (get-node-icon node-entity))
         node-icon (if (config/db-based-graph?)
                     node-icon*
                     (or (when-let [icon' (get-in node-entity [:block/properties :icon])]
                           [:span icon'])
                         node-icon*))]
-    (when-not (or (string/blank? node-icon) (and (contains? #{"letter-n" "file"} node-icon) (:not-text-or-page? opts)))
+    (when-not (or (string/blank? node-icon) (and (contains? #{"letter-n" "letter-p" "hash" "file"} node-icon) (:not-text-or-page? opts)))
       [:div.icon-cp-container.flex.items-center
        (merge {:style {:color (or (:color node-icon) "inherit")}}
               (select-keys opts [:class]))