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) (if (invalid-graph-name? @*graph-name)
(invalid-graph-name-warning) (invalid-graph-name-warning)
(p/let [repo (repo-handler/new-db! @*graph-name)] (p/let [repo (repo-handler/new-db! @*graph-name)]
(when @*cloud? (p/do!
(p/let [_create-result (rtc-handler/<rtc-create-graph! repo) (when @*cloud?
_start-result (rtc-handler/<rtc-start! repo)] (p/do!
;; TODO: can't pr-str result (rtc-handler/<rtc-create-graph! repo)
(state/close-modal!)))))))] (rtc-handler/<rtc-start! repo)))
(state/close-modal!))))))]
[:div.new-graph.flex.flex-col.p-4.gap-4 [:div.new-graph.flex.flex-col.p-4.gap-4
[:h1.title.mb-4 "Create new graph: "] [:h1.title.mb-4 "Create new graph: "]
[:input.form-input {:value @*graph-name [: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 bean/->clj (get-in [:value :value])))
(js/console.error "Unexpected webworker error:" data)) (js/console.error "Unexpected webworker error:" data))
(if (string? 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)) (handle (keyword e) wrapped-worker payload))
(js/console.error "Worker received invalid data from worker: " data)))))))) (js/console.error "Worker received invalid data from worker: " data))))))))

View File

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

View File

@ -97,7 +97,7 @@
(defn post-message (defn post-message
[type data] [type data]
(when (exists? js/self) (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 (defn get-pool-name
[graph-name] [graph-name]