fix: put check? in the go block

pull/6731/head
Tienson Qin 2022-09-14 19:48:01 +08:00
parent 376cda0bd3
commit a1e5d72925
1 changed files with 24 additions and 25 deletions

View File

@ -2776,35 +2776,34 @@
(let [*sync-state (atom (sync-state))
current-user-uuid (user/user-uuid)
repo (state/get-current-repo)]
(when (graph-sync-off? repo)
(go
(when @network-online-cursor
(<! (p->c (persist-var/-load graphs-txid)))
(go
(when (and (graph-sync-off? repo) @network-online-cursor)
(<! (p->c (persist-var/-load graphs-txid)))
(let [[user-uuid graph-uuid txid] @graphs-txid]
(when (and user-uuid graph-uuid txid
(user/logged-in?)
repo
(not (config/demo-graph? repo)))
(when-some [sm (sync-manager-singleton current-user-uuid graph-uuid
(config/get-repo-dir repo) repo
txid *sync-state)]
(when (check-graph-belong-to-current-user current-user-uuid user-uuid)
(if-not (<! (<check-remote-graph-exists graph-uuid)) ; remote graph has been deleted
(clear-graphs-txid! repo)
(do
(state/set-file-sync-state repo @*sync-state)
(state/set-file-sync-manager sm)
(let [[user-uuid graph-uuid txid] @graphs-txid]
(when (and user-uuid graph-uuid txid
(user/logged-in?)
repo
(not (config/demo-graph? repo)))
(when-some [sm (sync-manager-singleton current-user-uuid graph-uuid
(config/get-repo-dir repo) repo
txid *sync-state)]
(when (check-graph-belong-to-current-user current-user-uuid user-uuid)
(if-not (<! (<check-remote-graph-exists graph-uuid)) ; remote graph has been deleted
(clear-graphs-txid! repo)
(do
(state/set-file-sync-state repo @*sync-state)
(state/set-file-sync-manager sm)
;; update global state when *sync-state changes
(add-watch *sync-state ::update-global-state
(fn [_ _ _ n]
(state/set-file-sync-state repo n)))
;; update global state when *sync-state changes
(add-watch *sync-state ::update-global-state
(fn [_ _ _ n]
(state/set-file-sync-state repo n)))
(.start sm)
(.start sm)
(offer! remote->local-full-sync-chan true)
(offer! full-sync-chan true))))))))))))
(offer! remote->local-full-sync-chan true)
(offer! full-sync-chan true)))))))))))
;;; ### some add-watches