Browse Source

fix: deprecate :macros property for db graphs

It's not used much and would require building a new UI since
we don't have one yet for a :map type property
Gabriel Horner 1 year ago
parent
commit
e0c6cc1514

+ 3 - 1
deps/graph-parser/src/logseq/graph_parser/exporter.cljs

@@ -297,7 +297,9 @@
   ;; Already imported via a datascript attribute i.e. have :attribute on property config
   [:tags :alias :collapsed
    ;; Not supported as they have been ignored for a long time and cause invalid built-in pages
-   :now :later :doing :done :canceled :cancelled :in-progress :todo :wait :waiting])
+   :now :later :doing :done :canceled :cancelled :in-progress :todo :wait :waiting
+   ;; deprecated in db graphs
+   :macros :logseq.query/nlp-date])
 
 (defn- pre-update-properties
   "Updates page and block properties before their property types are inferred"

+ 12 - 10
src/main/frontend/components/block.cljs

@@ -1424,16 +1424,18 @@
   [name config arguments]
   (if-let [block-uuid (:block/uuid config)]
     (let [format (get-in config [:block :block/format] :markdown)
-          properties (-> (db/entity [:block/uuid block-uuid])
-                         (:block/page)
-                         (:db/id)
-                         (db/entity)
-                         :block/properties)
-          macros (pu/lookup-by-name properties :macros)
-          macro-content (or
-                         (get macros name)
-                         (get (state/get-macros) name)
-                         (get (state/get-macros) (keyword name)))
+          ;; :macros is deprecated for db graphs
+          macros-from-property (when (config/local-file-based-graph? (state/get-current-repo))
+                                 (-> (db/entity [:block/uuid block-uuid])
+                                     (:block/page)
+                                     (:db/id)
+                                     (db/entity)
+                                     :block/properties
+                                     :macros
+                                     (get name)))
+          macro-content (or macros-from-property
+                            (get (state/get-macros) name)
+                            (get (state/get-macros) (keyword name)))
           macro-content (cond
                           (= (str name) "img")
                           (case (count arguments)