|
|
@@ -148,23 +148,21 @@
|
|
|
|
|
|
(defn <download-graph
|
|
|
[state repo graph-uuid]
|
|
|
- (go-try
|
|
|
- (let [{:keys [url]}
|
|
|
- (<? (ws/<send&receive state {:action "full-download-graph"
|
|
|
- :graph-uuid graph-uuid}))
|
|
|
- {:keys [status body] :as r} (<! (http/get url))
|
|
|
- repo (str "logseq_db_" repo)]
|
|
|
- (if (not= 200 status)
|
|
|
- (ex-info "<download-graph failed" r)
|
|
|
- (let [^js worker-obj (:worker/object @worker-state/*state)
|
|
|
- all-blocks (transit/read transit-r body)]
|
|
|
- (worker-state/set-rtc-downloading-graph! true)
|
|
|
- (op-mem-layer/init-empty-ops-store! repo)
|
|
|
- (<? (<transact-remote-all-blocks-to-sqlite all-blocks repo graph-uuid))
|
|
|
- (op-mem-layer/update-graph-uuid! repo graph-uuid)
|
|
|
- (prn ::download-graph repo (@@#'op-mem-layer/*ops-store repo))
|
|
|
- (<! (op-mem-layer/<sync-to-idb-layer! repo))
|
|
|
- (<! (p->c
|
|
|
- (p/do!
|
|
|
- (.storeMetadata worker-obj repo (pr-str {:graph/uuid (:graph-uuid r)})))))
|
|
|
- (worker-state/set-rtc-downloading-graph! false))))))
|
|
|
+ (let [^js worker-obj (:worker/object @worker-state/*state)]
|
|
|
+ (go-try
|
|
|
+ (let [{:keys [url]}
|
|
|
+ (<? (ws/<send&receive state {:action "full-download-graph"
|
|
|
+ :graph-uuid graph-uuid}))
|
|
|
+ {:keys [status body] :as r} (<! (http/get url))
|
|
|
+ repo (str "logseq_db_" repo)]
|
|
|
+ (if (not= 200 status)
|
|
|
+ (ex-info "<download-graph failed" r)
|
|
|
+ (let [all-blocks (transit/read transit-r body)]
|
|
|
+ (worker-state/set-rtc-downloading-graph! true)
|
|
|
+ (op-mem-layer/init-empty-ops-store! repo)
|
|
|
+ (<? (<transact-remote-all-blocks-to-sqlite all-blocks repo graph-uuid))
|
|
|
+ (op-mem-layer/update-graph-uuid! repo graph-uuid)
|
|
|
+ (prn ::download-graph repo (@@#'op-mem-layer/*ops-store repo))
|
|
|
+ (<! (op-mem-layer/<sync-to-idb-layer! repo))
|
|
|
+ (<! (p->c (.storeMetadata worker-obj repo (pr-str {:graph/uuid graph-uuid}))))
|
|
|
+ (worker-state/set-rtc-downloading-graph! false)))))))
|