mirror of https://github.com/logseq/logseq
refactor(rtc): remake rtc-download-info-list
parent
1db86be435
commit
91a1372dfb
|
@ -67,7 +67,6 @@
|
|||
(reset! *sqlite sqlite)
|
||||
nil)))
|
||||
|
||||
|
||||
(def repo-path "/db.sqlite")
|
||||
|
||||
(defn- <export-db-file
|
||||
|
@ -104,9 +103,9 @@
|
|||
ffirst)]
|
||||
(try
|
||||
(let [data (sqlite-util/transit-read content)]
|
||||
(if-let [addresses (:addresses data)]
|
||||
(assoc data :addresses (bean/->js addresses))
|
||||
data))
|
||||
(if-let [addresses (:addresses data)]
|
||||
(assoc data :addresses (bean/->js addresses))
|
||||
data))
|
||||
(catch :default _e ; TODO: remove this once db goes to test
|
||||
(edn/read-string content))))))
|
||||
|
||||
|
@ -630,11 +629,7 @@
|
|||
|
||||
(rtc-download-info-list
|
||||
[this token graph-uuid]
|
||||
(async-util/c->p
|
||||
(async/go
|
||||
(let [state (or @rtc-core/*state
|
||||
(<! (rtc-core/<init-state token false)))]
|
||||
(<? (rtc-updown/<download-info-list state graph-uuid))))))
|
||||
(js/Promise. (rtc-core2/new-task--download-info-list token graph-uuid)))
|
||||
|
||||
(rtc-snapshot-graph
|
||||
[this token graph-uuid]
|
||||
|
@ -679,10 +674,10 @@
|
|||
|
||||
(comment
|
||||
(defn <remove-all-files!
|
||||
"!! Dangerous: use it only for development."
|
||||
[]
|
||||
(p/let [all-files (<list-all-files)
|
||||
files (filter #(= (.-kind %) "file") all-files)
|
||||
dirs (filter #(= (.-kind %) "directory") all-files)
|
||||
_ (p/all (map (fn [file] (.remove file)) files))]
|
||||
(p/all (map (fn [dir] (.remove dir)) dirs)))))
|
||||
"!! Dangerous: use it only for development."
|
||||
[]
|
||||
(p/let [all-files (<list-all-files)
|
||||
files (filter #(= (.-kind %) "file") all-files)
|
||||
dirs (filter #(= (.-kind %) "directory") all-files)
|
||||
_ (p/all (map (fn [file] (.remove file)) files))]
|
||||
(p/all (map (fn [dir] (.remove dir)) dirs)))))
|
||||
|
|
|
@ -313,6 +313,11 @@
|
|||
(let [{:keys [get-ws-create-task]} (new-task--get-ws-create--memoized (get-ws-url token))]
|
||||
(r.upload-download/new-task--request-download-graph get-ws-create-task graph-uuid)))
|
||||
|
||||
(defn new-task--download-info-list
|
||||
[token graph-uuid]
|
||||
(let [{:keys [get-ws-create-task]} (new-task--get-ws-create--memoized (get-ws-url token))]
|
||||
(r.upload-download/new-task--download-info-list get-ws-create-task graph-uuid)))
|
||||
|
||||
;;; ================ API (ends) ================
|
||||
|
||||
;;; subscribe debug state ;;;
|
||||
|
|
|
@ -70,7 +70,6 @@
|
|||
nil)
|
||||
(throw (ex-info "upload-graph failed" {:upload-resp upload-resp})))))))
|
||||
|
||||
|
||||
(def ^:private block-type-kw->str
|
||||
{:block-type/property "property"
|
||||
:block-type/class "class"
|
||||
|
@ -183,6 +182,12 @@
|
|||
(r.client/send&recv get-ws-create-task {:action "download-graph"
|
||||
:graph-uuid graph-uuid})))
|
||||
|
||||
(defn new-task--download-info-list
|
||||
[get-ws-create-task graph-uuid]
|
||||
(m/join :download-info-list
|
||||
(r.client/send&recv get-ws-create-task {:action "download-info-list"
|
||||
:graph-uuid graph-uuid})))
|
||||
|
||||
(defn <wait-download-info-ready
|
||||
[state download-info-uuid graph-uuid timeout-ms]
|
||||
(let [init-interval 1000
|
||||
|
@ -227,10 +232,3 @@
|
|||
(<! (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)))))))
|
||||
|
||||
(defn <download-info-list
|
||||
[state graph-uuid]
|
||||
(go-try
|
||||
(:download-info-list
|
||||
(<? (ws/<send&receive state {:action "download-info-list"
|
||||
:graph-uuid graph-uuid})))))
|
||||
|
|
Loading…
Reference in New Issue