Procházet zdrojové kódy

No need to set block ids for db based graphs

Tienson Qin před 2 roky
rodič
revize
261b5a6b28

+ 9 - 8
src/main/frontend/handler/editor.cljs

@@ -841,14 +841,15 @@
   "Persist block uuid to file if the uuid is valid, and it's not persisted in file.
   "Persist block uuid to file if the uuid is valid, and it's not persisted in file.
    Accepts a list of uuids."
    Accepts a list of uuids."
   [block-ids]
   [block-ids]
-  (let [block-ids (remove nil? block-ids)
-        col (map (fn [block-id]
-                   (when-let [block (db/entity [:block/uuid block-id])]
-                     (when-not (:block/pre-block? block)
-                       [block-id :id (str block-id)])))
-                 block-ids)
-        col (remove nil? col)]
-    (editor-property/batch-set-block-property! col)))
+  (when-not (config/db-based-graph? (state/get-current-repo))
+    (let [block-ids (remove nil? block-ids)
+          col (map (fn [block-id]
+                     (when-let [block (db/entity [:block/uuid block-id])]
+                       (when-not (:block/pre-block? block)
+                         [block-id :id (str block-id)])))
+                block-ids)
+          col (remove nil? col)]
+      (editor-property/batch-set-block-property! col))))
 
 
 (defn copy-block-ref!
 (defn copy-block-ref!
   ([block-id]
   ([block-id]

+ 19 - 16
src/main/frontend/handler/property.cljs

@@ -116,24 +116,26 @@
 
 
 (defn- upsert-property!
 (defn- upsert-property!
   [repo property k-name property-uuid property-type]
   [repo property k-name property-uuid property-type]
-  (when (and property (nil? (:block/type property)))
-    (db/transact! repo [(outliner-core/block-with-updated-at
-                         {:block/schema {:type property-type}
-                          :block/uuid property-uuid
-                          :block/type "property"})]
-      {:outliner-op :update-property}))
-  (when (nil? property) ;if property not exists yet
-    (db/transact! repo [(outliner-core/block-with-timestamps
-                         {:block/schema {:type property-type}
-                          :block/original-name k-name
-                          :block/name (util/page-name-sanity-lc k-name)
-                          :block/uuid property-uuid
-                          :block/type "property"})]
-      {:outliner-op :create-new-property})))
+  (let [k-name (name k-name)]
+    (when (and property (nil? (:block/type property)))
+     (db/transact! repo [(outliner-core/block-with-updated-at
+                          {:block/schema {:type property-type}
+                           :block/uuid property-uuid
+                           :block/type "property"})]
+       {:outliner-op :update-property}))
+    (when (nil? property) ;if property not exists yet
+      (db/transact! repo [(outliner-core/block-with-timestamps
+                           {:block/schema {:type property-type}
+                            :block/original-name k-name
+                            :block/name (util/page-name-sanity-lc k-name)
+                            :block/uuid property-uuid
+                            :block/type "property"})]
+        {:outliner-op :create-new-property}))))
 
 
 (defn add-property!
 (defn add-property!
   [repo block k-name v & {:keys [old-value]}]
   [repo block k-name v & {:keys [old-value]}]
-  (let [property (db/pull repo '[*] [:block/name (gp-util/page-name-sanity-lc k-name)])
+  (let [k-name (name k-name)
+        property (db/pull repo '[*] [:block/name (gp-util/page-name-sanity-lc k-name)])
         v (if property v (or v ""))]
         v (if property v (or v ""))]
     (when (some? v)
     (when (some? v)
       (let [property-uuid (or (:block/uuid property) (random-uuid))
       (let [property-uuid (or (:block/uuid property) (random-uuid))
@@ -262,7 +264,8 @@
 (defn class-add-property!
 (defn class-add-property!
   [repo class k-name]
   [repo class k-name]
   (when (= "class" (:block/type class))
   (when (= "class" (:block/type class))
-    (let [property (db/pull repo '[*] [:block/name (gp-util/page-name-sanity-lc k-name)])
+    (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) (random-uuid))
           property-type (get-in property [:block/schema :type] :default)
           property-type (get-in property [:block/schema :type] :default)
           {:keys [properties] :as class-schema} (:block/schema class)
           {:keys [properties] :as class-schema} (:block/schema class)