Parcourir la source

fix: update <transact-data caller, remove unused build-upsert-blocks

rcmerci il y a 2 ans
Parent
commit
7bca037e71

+ 0 - 20
deps/outliner/src/logseq/outliner/pipeline.cljs

@@ -30,26 +30,6 @@
     (when (some? v')
       [a v'])))
 
-(defn build-upsert-blocks
-  [blocks deleted-block-uuids db-after]
-  (let [t-writer (t/writer :json)]
-    (->> blocks
-         (remove (fn [b] (contains? deleted-block-uuids (:block/uuid b))))
-         (map (fn [b]
-                (let [datoms (d/datoms db-after :eavt (:db/id b))]
-                  (assoc b :datoms
-                         (->> datoms
-                              (keep
-                               (partial datom->av-vector db-after))
-                              (t/write t-writer))))))
-         (map (fn [b]
-                (if-some [page-uuid (:block/uuid (d/entity db-after (:db/id (:block/page b))))]
-                  (assoc b :page_uuid page-uuid)
-                  b)))
-         (map (fn [b]
-                (let [uuid (or (:block/uuid b) (d/squuid))]
-                  (assoc b :block/uuid uuid)))))))
-
 ;; non recursive query
 (defn ^:api get-block-parents
   [db block-id {:keys [depth] :or {depth 100}}]

+ 3 - 10
src/main/frontend/db/rtc/full_upload_download_graph.cljs

@@ -117,18 +117,11 @@
   [all-blocks repo]
   (go-try
    (let [{:keys [t blocks]} all-blocks
-         conn (d/create-conn db-schema/schema-for-db-based-graph)
          blocks* (replace-db-id-with-temp-id blocks)
          blocks-with-page-id (fill-block-fields blocks*)]
-     (d/transact! conn blocks-with-page-id)
-     (let [db (d/db conn)
-           blocks*
-           (d/pull-many db '[*] (keep (fn [b] (when-let [uuid (:block/uuid b)] [:block/uuid uuid])) blocks))
-           blocks** (outliner-pipeline/build-upsert-blocks blocks* nil db)]
-       (<? (p->c (persist-db/<new repo)))
-       ;; FIXME: pass tx-data tx-meta instead
-       (<? (p->c (persist-db/<transact-data repo blocks** nil)))
-       (op-mem-layer/update-local-tx! repo t)))))
+     (<? (p->c (persist-db/<new repo)))
+     (<? (p->c (persist-db/<transact-data repo blocks-with-page-id nil)))
+     (op-mem-layer/update-local-tx! repo t))))
 
 
 (defn <download-graph