Просмотр исходного кода

fix: use db/new-block-id to keep the order for :block/uuid

Tienson Qin 2 лет назад
Родитель
Сommit
5162598665

+ 2 - 2
deps/outliner/src/logseq/outliner/pipeline.cljs

@@ -47,7 +47,7 @@
                   (assoc b :page_uuid page-uuid)
                   b)))
          (map (fn [b]
-                (let [uuid (or (:block/uuid b) (random-uuid))]
+                (let [uuid (or (:block/uuid b) (d/squuid))]
                   (assoc b :block/uuid uuid)))))))
 
 ;; non recursive query
@@ -148,4 +148,4 @@
   [tx-report blocks]
   (let [refs-tx (compute-block-path-refs tx-report blocks)
         truncate-refs-tx (map (fn [m] [:db/retract (:db/id m) :block/path-refs]) refs-tx)]
-    (concat truncate-refs-tx refs-tx)))
+    (concat truncate-refs-tx refs-tx)))

+ 4 - 4
src/main/frontend/components/property.cljs

@@ -121,7 +121,7 @@
                                (remove property-handler/internal-builtin-schema-types)
                                (map (comp string/capitalize name))
                                (map (fn [type]
-                                      {:label type
+                                      {:label (if (= type "Default") "Text" type)
                                        :disabled built-in-property?
                                        :value type
                                        :selected (= (keyword (string/lower-case type))
@@ -427,7 +427,8 @@
         properties (if class-schema?
                      (let [properties (:properties (:block/schema block))]
                        (map (fn [k] [k nil]) properties))
-                     (:block/properties block))
+                     (->> (:block/properties block)
+                          (sort-by first)))
         alias (set (map :block/uuid (:block/alias block)))
         tags (set (map :block/uuid (:block/tags block)))
         alias-properties (when (seq alias)
@@ -455,8 +456,7 @@
                                           (seq alias-properties)
                                           (seq properties))
                                   remove-built-in-properties
-                                  (remove (fn [[id _]] ((set classes-properties) id)))
-                                  (sort-by first))
+                                  (remove (fn [[id _]] ((set classes-properties) id))))
         ;; This section produces own-properties and full-hidden-properties
         hide-with-property-id (fn [property-id]
                                 (let [eid (if (uuid? property-id) [:block/uuid property-id] property-id)]

+ 4 - 4
src/main/frontend/handler/db_based/property.cljs

@@ -96,7 +96,7 @@
   [repo k-name schema {:keys [property-uuid]}]
   (let [property (db/entity [:block/name (gp-util/page-name-sanity-lc k-name)])
         k-name (name k-name)
-        property-uuid (or (:block/uuid property) property-uuid (random-uuid))]
+        property-uuid (or (:block/uuid property) property-uuid (db/new-block-id))]
     (when (and property (nil? (:block/type property)))
       (db/transact! repo [(outliner-core/block-with-updated-at
                            {:block/schema schema
@@ -119,7 +119,7 @@
         property (db/pull repo '[*] [:block/name (gp-util/page-name-sanity-lc k-name)])
         v (if property v (or v ""))]
     (when (some? v)
-      (let [property-uuid (or (:block/uuid property) (random-uuid))
+      (let [property-uuid (or (:block/uuid property) (db/new-block-id))
             {:keys [type cardinality]} (:block/schema property)
             multiple-values? (= cardinality :many)
             infer-schema (when-not type (infer-schema-from-input-string v))
@@ -220,7 +220,7 @@
   (when (= "class" (:block/type class))
     (let [k-name (name k-name)
           property (db/pull repo '[*] [:block/name (gp-util/page-name-sanity-lc k-name)])
-          property-uuid (or (:block/uuid property) (random-uuid))
+          property-uuid (or (:block/uuid property) (db/new-block-id))
           property-type (get-in property [:block/schema :type] :default)
           {:keys [properties] :as class-schema} (:block/schema class)
           _ (upsert-property! repo k-name {:type property-type}
@@ -249,7 +249,7 @@
   [repo block-ids k-name v]
   (let [k-name (name k-name)
         property (db/entity repo [:block/name (gp-util/page-name-sanity-lc k-name)])
-        property-uuid (or (:block/uuid property) (random-uuid))
+        property-uuid (or (:block/uuid property) (db/new-block-id))
         type (:type (:block/schema property))
         infer-schema (when-not type (infer-schema-from-input-string v))
         property-type (or type infer-schema :default)