Quellcode durchsuchen

chore: remove unused *sync-starting?

Tienson Qin vor 3 Jahren
Ursprung
Commit
5f8d8e832c
1 geänderte Dateien mit 25 neuen und 29 gelöschten Zeilen
  1. 25 29
      src/main/frontend/fs/sync.cljs

+ 25 - 29
src/main/frontend/fs/sync.cljs

@@ -2931,9 +2931,8 @@
 
 
 (declare network-online-cursor)
 (declare network-online-cursor)
 
 
-;; Prevent starting of multiple sync managers
-(def *sync-starting? (atom {}))
-(defn sync-start []
+(defn sync-start
+  []
   (go
   (go
     (let [*sync-state                 (atom (sync-state))
     (let [*sync-state                 (atom (sync-state))
           current-user-uuid           (user/user-uuid)
           current-user-uuid           (user/user-uuid)
@@ -2948,34 +2947,31 @@
                    repo
                    repo
                    (not (config/demo-graph? repo)))
                    (not (config/demo-graph? repo)))
           (try
           (try
-            (when-not (get @*sync-starting? graph-uuid)
-              (swap! *sync-starting? assoc graph-uuid true)
-              (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 graph-uuid @*sync-state)
-                      (state/set-file-sync-manager graph-uuid sm)
-
-                      ;; update global state when *sync-state changes
-                      (add-watch *sync-state ::update-global-state
-                                 (fn [_ _ _ n]
-                                   (state/set-file-sync-state graph-uuid n)))
-
-                      (state/set-state! [:file-sync/graph-state :current-graph-uuid] graph-uuid)
-
-                      (.start sm)
-
-                      (offer! remote->local-full-sync-chan true)
-                      (offer! full-sync-chan true)
-                      (swap! *sync-starting? assoc graph-uuid false))))))
+            (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 graph-uuid @*sync-state)
+                    (state/set-file-sync-manager graph-uuid sm)
+
+                    ;; update global state when *sync-state changes
+                    (add-watch *sync-state ::update-global-state
+                               (fn [_ _ _ n]
+                                 (state/set-file-sync-state graph-uuid n)))
+
+                    (state/set-state! [:file-sync/graph-state :current-graph-uuid] graph-uuid)
+
+                    (.start sm)
+
+                    (offer! remote->local-full-sync-chan true)
+                    (offer! full-sync-chan true)))))
             (catch :default e
             (catch :default e
               (prn "Sync start error: ")
               (prn "Sync start error: ")
-              (log/error :exception e)
-              (swap! *sync-starting? assoc graph-uuid false))))))))
+              (log/error :exception e)))))))
+  )
 
 
 ;;; ### some add-watches
 ;;; ### some add-watches