浏览代码

fix: incorrect properties warning for empty pages in db import

Also remove unused macros and tweaked test assertions from last import
commit
Gabriel Horner 1 年之前
父节点
当前提交
4fb25ff269

+ 2 - 17
deps/graph-parser/src/logseq/graph_parser/exporter.cljs

@@ -534,7 +534,7 @@
                         {:block/original-name new-class
                          :block/uuid (or (get-pid db new-class) (d/squuid))
                          :block/name (common-util/page-name-sanity-lc new-class)})))))
-          block*)]
+          (dissoc block* :block/properties))]
     {:block block' :properties-tx properties-tx}))
 
 (defn- handle-block-properties
@@ -579,20 +579,6 @@
                      (map #(add-uuid-to-page-map % page-names-to-uuids)))))
       block)))
 
-(defn- update-block-macros
-  [block db page-names-to-uuids]
-  (if (seq (:block/macros block))
-    (update block :block/macros
-            (fn [macros]
-              (mapv (fn [m]
-                      (-> m
-                          (update :block/properties
-                                  (fn [props]
-                                    (update-keys props #(cached-prop-name->uuid db page-names-to-uuids %))))
-                          (assoc :block/uuid (d/squuid))))
-                    macros)))
-    block))
-
 (defn- fix-pre-block-references
   [{:block/keys [parent page] :as block} pre-blocks]
   (cond-> block
@@ -621,7 +607,6 @@
         block' (-> block-after-built-in-props
                    (fix-pre-block-references pre-blocks)
                    (fix-block-name-lookup-ref db page-names-to-uuids)
-                   (update-block-macros db page-names-to-uuids)
                    (update-block-refs page-names-to-uuids options)
                    (update-block-tags db tag-classes page-names-to-uuids)
                    (update-block-marker options)
@@ -770,7 +755,7 @@
   pages that are now properties"
   [pages-tx old-properties existing-pages import-state]
   (let [new-properties (set/difference (set (keys @(:property-schemas import-state))) (set old-properties))
-        _ (prn :new-properties new-properties)
+        _ (when (seq new-properties) (prn :new-properties new-properties))
         [properties-tx pages-tx'] ((juxt filter remove)
                                    #(contains? new-properties (keyword (:block/name %))) pages-tx)
         property-pages-tx (map (fn [{:block/keys [original-name uuid]}]

+ 2 - 2
deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs

@@ -235,7 +235,7 @@
           tag-page (find-page-by-name @conn "Movie")
           another-tag-page (find-page-by-name @conn "p0")]
       (is (= (:block/content block) "Inception")
-          "configured tagged block block with :tag-classes tag strips tag from content")
+          "tagged block with configured tag strips tag from content")
 
       (is (= ["class"] (:block/type tag-page))
           "configured tag page in :tag-classes is a class")
@@ -244,4 +244,4 @@
 
       (is (= {:block/tags [:user.class/Movie]}
              (readable-properties @conn (find-page-by-name @conn "Interstellar")))
-          "configured tagged page has tags imported as a class"))))
+          "tagged page has configured tag imported as a class"))))

+ 1 - 0
deps/graph-parser/test/resources/exporter-test-graph/pages/contents.md

@@ -0,0 +1 @@
+-