refactor(rtc): remake rtc-request-download-graph

pull/11293/head
rcmerci 2024-05-05 20:54:33 +08:00
parent 0164695483
commit 1db86be435
3 changed files with 14 additions and 13 deletions

View File

@ -611,11 +611,7 @@
;; ================================================================
(rtc-request-download-graph
[this token graph-uuid]
(async-util/c->p
(async/go
(let [state (or @rtc-core/*state
(<! (rtc-core/<init-state token false)))]
(<? (rtc-updown/<request-download-graph state graph-uuid))))))
(js/Promise. (rtc-core2/new-task--request-download-graph token graph-uuid)))
(rtc-wait-download-graph-info-ready
[this repo token download-info-uuid graph-uuid timeout-ms]

View File

@ -308,6 +308,13 @@
(r.ex/->map (ex-info "Not found db-conn" {:type :rtc.exception/not-found-db-conn
:repo repo})))))
(defn new-task--request-download-graph
[token graph-uuid]
(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)))
;;; ================ API (ends) ================
;;; subscribe debug state ;;;
(defonce ^:private *last-subscribe-canceler (atom nil))

View File

@ -71,7 +71,7 @@
(throw (ex-info "upload-graph failed" {:upload-resp upload-resp})))))))
(def block-type-kw->str
(def ^:private block-type-kw->str
{:block-type/property "property"
:block-type/class "class"
:block-type/whiteboard "whiteboard"
@ -177,13 +177,11 @@
;; async download-graph ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn <request-download-graph
[state graph-uuid]
(go-try
(let [{:keys [download-info-uuid]}
(<? (ws/<send&receive state {:action "download-graph"
:graph-uuid graph-uuid}))]
download-info-uuid)))
(defn new-task--request-download-graph
[get-ws-create-task graph-uuid]
(m/join :download-info-uuid
(r.client/send&recv get-ws-create-task {:action "download-graph"
:graph-uuid graph-uuid})))
(defn <wait-download-info-ready
[state download-info-uuid graph-uuid timeout-ms]