|
@@ -79,7 +79,8 @@
|
|
|
[:toggle-auto-push-client-ops-chan :any]
|
|
[:toggle-auto-push-client-ops-chan :any]
|
|
|
[:*auto-push-client-ops? :any]
|
|
[:*auto-push-client-ops? :any]
|
|
|
[:force-push-client-ops-chan :any]
|
|
[:force-push-client-ops-chan :any]
|
|
|
- [:counter :any]])
|
|
|
|
|
|
|
+ [:counter :any]
|
|
|
|
|
+ [:dev-mode? :boolean]])
|
|
|
|
|
|
|
|
(def state-validator
|
|
(def state-validator
|
|
|
(let [validator (m/validator state-schema)]
|
|
(let [validator (m/validator state-schema)]
|
|
@@ -932,7 +933,7 @@
|
|
|
;; :block-uuids [page-block-uuid]})))))
|
|
;; :block-uuids [page-block-uuid]})))))
|
|
|
|
|
|
|
|
(defn init-state
|
|
(defn init-state
|
|
|
- [ws data-from-ws-chan repo token]
|
|
|
|
|
|
|
+ [ws data-from-ws-chan repo token dev-mode?]
|
|
|
;; {:post [(m/validate state-schema %)]}
|
|
;; {:post [(m/validate state-schema %)]}
|
|
|
{:*rtc-state (atom :closed :validator rtc-state-validator)
|
|
{:*rtc-state (atom :closed :validator rtc-state-validator)
|
|
|
:*graph-uuid (atom nil)
|
|
:*graph-uuid (atom nil)
|
|
@@ -947,7 +948,7 @@
|
|
|
:*stop-rtc-loop-chan (atom nil)
|
|
:*stop-rtc-loop-chan (atom nil)
|
|
|
:force-push-client-ops-chan (chan (async/sliding-buffer 1))
|
|
:force-push-client-ops-chan (chan (async/sliding-buffer 1))
|
|
|
:*ws (atom ws)
|
|
:*ws (atom ws)
|
|
|
-
|
|
|
|
|
|
|
+ :dev-mode? dev-mode?
|
|
|
;; used to trigger state watch
|
|
;; used to trigger state watch
|
|
|
:counter 0})
|
|
:counter 0})
|
|
|
|
|
|
|
@@ -971,22 +972,23 @@
|
|
|
|
|
|
|
|
;; FIXME: token might be expired
|
|
;; FIXME: token might be expired
|
|
|
(defn <init-state
|
|
(defn <init-state
|
|
|
- [repo token reset-*state?]
|
|
|
|
|
|
|
+ [repo token reset-*state? & {:keys [dev-mode?]
|
|
|
|
|
+ :or {dev-mode? false}}]
|
|
|
(go
|
|
(go
|
|
|
(let [data-from-ws-chan (chan (async/sliding-buffer 100))
|
|
(let [data-from-ws-chan (chan (async/sliding-buffer 100))
|
|
|
ws-opened-ch (chan)
|
|
ws-opened-ch (chan)
|
|
|
ws (ws/ws-listen token data-from-ws-chan ws-opened-ch)]
|
|
ws (ws/ws-listen token data-from-ws-chan ws-opened-ch)]
|
|
|
(<! ws-opened-ch)
|
|
(<! ws-opened-ch)
|
|
|
- (let [state (init-state ws data-from-ws-chan repo token)]
|
|
|
|
|
|
|
+ (let [state (init-state ws data-from-ws-chan repo token dev-mode?)]
|
|
|
(when reset-*state?
|
|
(when reset-*state?
|
|
|
(reset! *state state)
|
|
(reset! *state state)
|
|
|
(swap! *state update :counter inc))
|
|
(swap! *state update :counter inc))
|
|
|
state))))
|
|
state))))
|
|
|
|
|
|
|
|
(defn <start-rtc
|
|
(defn <start-rtc
|
|
|
- [repo conn token]
|
|
|
|
|
|
|
+ [repo conn token dev-mode?]
|
|
|
(go
|
|
(go
|
|
|
- (let [state (<! (<init-state repo token true))
|
|
|
|
|
|
|
+ (let [state (<! (<init-state repo token true {:dev-mode? dev-mode?}))
|
|
|
state-for-asset-sync (asset-sync/init-state-from-rtc-state state)
|
|
state-for-asset-sync (asset-sync/init-state-from-rtc-state state)
|
|
|
_ (reset! asset-sync/*asset-sync-state state-for-asset-sync)
|
|
_ (reset! asset-sync/*asset-sync-state state-for-asset-sync)
|
|
|
config (worker-state/get-config repo)]
|
|
config (worker-state/get-config repo)]
|