Procházet zdrojové kódy

enhance(perf): reduce <get-block calls for children

Tienson Qin před 7 měsíci
rodič
revize
b6c06b692a

+ 1 - 2
deps/db/src/logseq/db/common/initial_data.cljs

@@ -254,8 +254,7 @@
                           (fn [block]
                             (-> block
                                 (assoc :block.temp/has-children? (some? (:block/_parent block)))
-                                (dissoc :block/tx-id :block/created-at :block/updated-at)
-                                entity->map))
+                                (entity->map)))
                           children)))
             block' (cond-> (entity->map block {:properties (set properties)})
                      block-refs-count?

+ 2 - 1
src/main/frontend/db/async.cljs

@@ -112,10 +112,11 @@
                {:keys [block children]} (first result)]
          (when-not skip-transact?
            (let [conn (db/get-db graph false)
-                 load-status' (if (or children? children-only?) :full :self)
+                 load-status' (if (and (or children? children-only?) (empty? properties)) :full :self)
                  block-load-status-tx (when block
                                         [{:db/id (:db/id block)
                                           :block.temp/load-status load-status'}])
+                 children (map (fn [child] (assoc child :block.temp/load-status :self)) children)
                  block-and-children (if block (cons block children) children)
                  affected-keys [[:frontend.worker.react/block (:db/id block)]]
                  tx-data (->> (remove (fn [b] (:block.temp/load-status (db/entity (:db/id b)))) block-and-children)