|
@@ -5,6 +5,7 @@
|
|
|
(:require [cljs-http.client :as http]
|
|
|
[cljs.core.async :as async :refer [<! go]]
|
|
|
[cljs.core.async.interop :refer [p->c]]
|
|
|
+ [clojure.string :as string]
|
|
|
[cognitect.transit :as transit]
|
|
|
[datascript.core :as d]
|
|
|
[frontend.worker.async-util :include-macros true :refer [<? go-try]]
|
|
@@ -12,12 +13,11 @@
|
|
|
[frontend.worker.rtc.ws :as ws :refer [<send!]]
|
|
|
[frontend.worker.state :as worker-state]
|
|
|
[frontend.worker.util :as worker-util]
|
|
|
+ [logseq.common.util.page-ref :as page-ref]
|
|
|
+ [logseq.db.frontend.content :as db-content]
|
|
|
[logseq.db.frontend.schema :as db-schema]
|
|
|
[logseq.outliner.core :as outliner-core]
|
|
|
- [logseq.db.frontend.content :as db-content]
|
|
|
- [promesa.core :as p]
|
|
|
- [clojure.string :as string]
|
|
|
- [logseq.common.util.page-ref :as page-ref]))
|
|
|
+ [promesa.core :as p]))
|
|
|
|
|
|
(def transit-r (transit/reader :json))
|
|
|
|
|
@@ -68,6 +68,34 @@
|
|
|
(<! (op-mem-layer/<sync-to-idb-layer! repo))
|
|
|
r))))))
|
|
|
|
|
|
+(defn <async-upload-graph
|
|
|
+ [state repo conn remote-graph-name]
|
|
|
+ (go
|
|
|
+ (let [{:keys [url key all-blocks-str]}
|
|
|
+ (with-sub-data-from-ws state
|
|
|
+ (<? (<send! state {:req-id (get-req-id) :action "presign-put-temp-s3-obj"}))
|
|
|
+ (let [all-blocks (export-as-blocks @conn)
|
|
|
+ all-blocks-str (transit/write (transit/writer :json) all-blocks)]
|
|
|
+ (merge (<! (get-result-ch)) {:all-blocks-str all-blocks-str})))]
|
|
|
+ (<! (http/put url {:body all-blocks-str}))
|
|
|
+ (let [r (<? (ws/<send&receive state {:action "upload-graph"
|
|
|
+ :s3-key key
|
|
|
+ :graph-name remote-graph-name}))]
|
|
|
+ (if-not (:graph-uuid r)
|
|
|
+ (ex-info "upload graph failed" r)
|
|
|
+ (let [^js worker-obj (:worker/object @worker-state/*state)]
|
|
|
+ (d/transact! conn
|
|
|
+ [{:db/ident :logseq.kv/graph-uuid :graph/uuid (:graph-uuid r)}
|
|
|
+ {:db/ident :logseq.kv/graph-local-tx :graph/local-tx "0"}])
|
|
|
+ (<! (p->c
|
|
|
+ (p/do!
|
|
|
+ (.storeMetadata worker-obj repo (pr-str {:graph/uuid (:graph-uuid r)})))))
|
|
|
+ (op-mem-layer/init-empty-ops-store! repo)
|
|
|
+ (op-mem-layer/update-graph-uuid! repo (:graph-uuid r))
|
|
|
+ (op-mem-layer/update-local-tx! repo 8)
|
|
|
+ (<! (op-mem-layer/<sync-to-idb-layer! repo))
|
|
|
+ r))))))
|
|
|
+
|
|
|
(def block-type-kw->str
|
|
|
{:block-type/property "property"
|
|
|
:block-type/class "class"
|