mirror of https://github.com/logseq/logseq
fix: add timeout between rtc stop and start
parent
e801118466
commit
38f1718fa3
|
@ -340,9 +340,7 @@
|
|||
(state/set-state! :rtc/uploading? false)
|
||||
;; No need to wait for rtc-start since it's a go loop that'll
|
||||
;; return a value once it's stopped
|
||||
(and (p/do!
|
||||
(rtc-handler/<rtc-stop!)
|
||||
(rtc-handler/<rtc-start! repo)) false))
|
||||
(and (rtc-handler/<rtc-start! repo) false))
|
||||
(p/catch (fn [error]
|
||||
(reset! *creating-db? false)
|
||||
(state/set-state! :rtc/uploading? false)
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
[frontend.db :as db]
|
||||
[logseq.db :as ldb]
|
||||
[logseq.db.sqlite.common-db :as sqlite-common-db]
|
||||
[frontend.handler.notification :as notification]))
|
||||
[frontend.handler.notification :as notification]
|
||||
[clojure.core.async :as async]))
|
||||
|
||||
(defn <rtc-create-graph!
|
||||
[repo]
|
||||
|
@ -37,20 +38,23 @@
|
|||
(fn []
|
||||
(state/set-state! :rtc/downloading-graph-uuid nil))))))))
|
||||
|
||||
(defn <rtc-stop!
|
||||
[]
|
||||
(when-let [^js worker @state/*db-worker]
|
||||
(.rtc-stop worker)))
|
||||
|
||||
(defn <rtc-start!
|
||||
[repo]
|
||||
(when-let [^js worker @state/*db-worker]
|
||||
(when (ldb/get-graph-rtc-uuid (db/get-db repo))
|
||||
(user-handler/<wrap-ensure-id&access-token
|
||||
;; TODO: `<rtc-stop!` can return a chan so that we can remove timeout usage
|
||||
(<rtc-stop!)
|
||||
(async/<! (async/timeout 100))
|
||||
(let [token (state/get-auth-id-token)]
|
||||
(.rtc-start worker repo token
|
||||
(state/sub [:ui/developer-mode?])))))))
|
||||
|
||||
(defn <rtc-stop!
|
||||
[]
|
||||
(when-let [^js worker @state/*db-worker]
|
||||
(.rtc-stop worker)))
|
||||
|
||||
;; TODO: shared graphs need `shared-by`, user name
|
||||
(defn <get-remote-graphs
|
||||
[]
|
||||
|
|
|
@ -179,9 +179,7 @@
|
|||
(srs/update-cards-due-count!)
|
||||
(state/pub-event! [:graph/ready graph])
|
||||
(if db-based?
|
||||
(p/do!
|
||||
(rtc-handler/<rtc-stop!)
|
||||
(rtc-handler/<rtc-start! graph))
|
||||
(rtc-handler/<rtc-start! graph)
|
||||
(file-sync-restart!))
|
||||
(when-let [dir-name (and (not db-based?) (config/get-repo-dir graph))]
|
||||
(fs/watch-dir! dir-name)))))))
|
||||
|
|
Loading…
Reference in New Issue