소스 검색

fix: rtc start shouldn't block app start

Tienson Qin 3 달 전
부모
커밋
ad5d469f75
2개의 변경된 파일8개의 추가작업 그리고 2개의 파일을 삭제
  1. 6 1
      src/main/frontend/worker/db_worker.cljs
  2. 2 1
      src/main/frontend/worker/rtc/ws_util.cljs

+ 6 - 1
src/main/frontend/worker/db_worker.cljs

@@ -814,7 +814,10 @@
      (when-not (:import-type start-opts)
        (c.m/<? (start-db! repo start-opts))
        (assert (some? (worker-state/get-datascript-conn repo))))
-     (m/? (rtc.core/new-task--rtc-start true)))))
+     ;; Don't wait for rtc started because the app will be slow to be ready
+     ;; for users.
+     (when @worker-state/*rtc-ws-url
+       (rtc.core/new-task--rtc-start true)))))
 
 (def broadcast-data-types
   (set (map
@@ -859,7 +862,9 @@
                                 ;; creating a new database or switching to another one requires re-initializing the service.
                                 (let [[graph opts] (ldb/read-transit-str (last args))]
                                   (p/let [service (<init-service! graph opts)]
+                                    (prn :debug :x1)
                                     (get-in service [:status :ready])
+                                    (prn :debug :x2)
                                     ;; wait for service ready
                                     (js-invoke (:proxy service) k args)))
 

+ 2 - 1
src/main/frontend/worker/rtc/ws_util.cljs

@@ -65,7 +65,8 @@
 (defn get-ws-url
   [token]
   (assert (some? token))
-  (gstring/format @worker-state/*rtc-ws-url token))
+  (when-let [url @worker-state/*rtc-ws-url]
+    (gstring/format url token)))
 
 (defn- gen-get-ws-create-map
   "Return a map with atom *current-ws and a task