fix: create rtc graph

pull/11055/head
Tienson Qin 2024-03-18 11:25:22 +08:00
parent 21bfece777
commit b423b52379
4 changed files with 18 additions and 14 deletions

View File

@ -320,11 +320,12 @@
(if (invalid-graph-name? @*graph-name)
(invalid-graph-name-warning)
(p/let [repo (repo-handler/new-db! @*graph-name)]
(when @*cloud?
(p/let [_create-result (rtc-handler/<rtc-create-graph! repo)
_start-result (rtc-handler/<rtc-start! repo)]
;; TODO: can't pr-str result
(state/close-modal!)))))))]
(p/do!
(when @*cloud?
(p/do!
(rtc-handler/<rtc-create-graph! repo)
(rtc-handler/<rtc-start! repo)))
(state/close-modal!))))))]
[:div.new-graph.flex.flex-col.p-4.gap-4
[:h1.title.mb-4 "Create new graph: "]
[:input.form-input {:value @*graph-name

View File

@ -55,6 +55,6 @@
(js/console.error "Unexpected webworker error:" (-> data bean/->clj (get-in [:value :value])))
(js/console.error "Unexpected webworker error:" data))
(if (string? data)
(let [[e payload] (util/profile "UI read transit: " (ldb/read-transit-str data))]
(let [[e payload] (ldb/read-transit-str data)]
(handle (keyword e) wrapped-worker payload))
(js/console.error "Worker received invalid data from worker: " data))))))))

View File

@ -1123,10 +1123,12 @@
(when reset-*state?
(reset! *state state)
(swap! *state update :counter inc))
(add-watch (:*rtc-state @*state) :update-rtc-state
(fn [_ _ _ _new]
(when (:*repo @*state)
(swap! *state update :counter (fnil inc 0)))))
(when-let [*rtc-state (:*rtc-state @*state)]
(add-watch *rtc-state
:update-rtc-state
(fn [_ _ _ _new]
(when (:*repo @*state)
(swap! *state update :counter (fnil inc 0))))))
state))))
(defn <start-rtc
@ -1186,8 +1188,9 @@
(add-watch *state :notify-main-thread
(fn [_ _ old new]
(when-let [repo @(:*repo new)]
(let [new-state (get-debug-state repo new)
(when-let [*repo (:*repo new)]
(let [repo @*repo
new-state (get-debug-state repo new)
old-state (get-debug-state repo old)]
(when (or (not= new-state old-state)
(= :open (:rtc-state new-state)))
@ -1195,5 +1198,5 @@
(add-watch op-mem-layer/*ops-store :update-ops-state
(fn [_ _ _ _new]
(when (:*repo @*state)
(when (and *state (:*repo @*state))
(swap! *state update :counter (fnil inc 0)))))

View File

@ -97,7 +97,7 @@
(defn post-message
[type data]
(when (exists? js/self)
(.postMessage js/self (frontend.worker.util/profile "Worker write transit: " (ldb/write-transit-str [type data])))))
(.postMessage js/self (ldb/write-transit-str [type data]))))
(defn get-pool-name
[graph-name]