Browse Source

fix: adding uuids on imported classes causes multiple bugs

Caused invalid blocks as properties that were on the same block
as new class had invalid uuids. Also caused content to have
incorrect mangled uuids. Part of LOG-2985
Gabriel Horner 2 years ago
parent
commit
356657d36b

+ 9 - 7
deps/graph-parser/src/logseq/graph_parser/exporter.cljs

@@ -33,19 +33,17 @@
   "Converts a tag block with class or returns nil if this tag should be removed
    because it has been moved"
   [tag-block tag-classes]
-  (if-let [new-tag (:block.temp/new-class tag-block)]
+  (if-let [new-class (:block.temp/new-class tag-block)]
     (sqlite-util/build-new-class
-     {:block/original-name new-tag
-      :block/name (common-util/page-name-sanity-lc new-tag)
-      :block/uuid (d/squuid)})
+     {:block/original-name new-class
+      :block/name (common-util/page-name-sanity-lc new-class)})
     (when (contains? tag-classes (:block/name tag-block))
       (-> tag-block
           add-missing-timestamps
           ;; don't use build-new-class b/c of timestamps
           (merge {:block/journal? false
                   :block/format :markdown
-                  :block/type "class"
-                  :block/uuid (d/squuid)})))))
+                  :block/type "class"})))))
 
 (defn- update-page-tags
   [block tag-classes names-uuids page-tags-uuid]
@@ -256,7 +254,11 @@
                                                options'))
             (seq classes-from-properties)
             ;; Add a map of {:block.temp/new-class TAG} to be processed later
-            (update :block/tags (fnil into []) (map #(hash-map :block.temp/new-class %) classes-from-properties))))
+            (update :block/tags
+                    (fnil into [])
+                    (map #(hash-map :block.temp/new-class %
+                                    :block/uuid (or (get-pid db %) (d/squuid)))
+                         classes-from-properties))))
         block)
       (dissoc :block/properties-text-values :block/properties-order :block/invalid-properties)))
 

+ 1 - 1
src/main/frontend/components/imports.cljs

@@ -343,7 +343,7 @@
      [:div.sm:flex.sm:items-start
       [:div.mt-3.text-center.sm:mt-0.sm:text-left
        [:h3#modal-headline.leading-6.font-medium
-        "(Optional) Properties to import as tag classes e.g. 'type':"]
+        "(Optional) Properties whose values are imported as tag classes e.g. 'type':"]
        [:span.text-xs
         "Properties are case insensitive and separated by commas"]]]
      [:input.form-input.block.w-full.sm:text-sm.sm:leading-5.my-2.mb-4

+ 1 - 2
src/main/frontend/modules/editor/undo_redo.cljs

@@ -6,8 +6,7 @@
             [clojure.set :as set]
             [medley.core :as medley]
             [frontend.handler.route :as route-handler]
-            [promesa.core :as p]
-            [frontend.util :as util]))
+            [promesa.core :as p]))
 
 ;;;; APIs