Bläddra i källkod

fix: more places to check sync-enabled

rcmerci 2 år sedan
förälder
incheckning
25049cd648

+ 2 - 1
src/main/frontend/components/header.cljs

@@ -235,7 +235,8 @@
               (ui/icon "search" {:size ui/icon-size})])))]]
 
      [:div.r.flex.drag-region
-      (when (and current-repo
+      (when (and sync-enabled?
+                 current-repo
                  (not (config/demo-graph? current-repo))
                  (user-handler/alpha-or-beta-user?))
         (fs-sync/indicator))

+ 5 - 3
src/main/frontend/components/settings.cljs

@@ -1,10 +1,12 @@
 (ns frontend.components.settings
   (:require [clojure.string :as string]
             [electron.ipc :as ipc]
+            [frontend.compile-config :as cconfig]
             [frontend.components.assets :as assets]
             [frontend.components.conversion :as conversion-component]
             [frontend.components.file-sync :as fs]
             [frontend.components.plugins :as plugins]
+            [frontend.components.shortcut2 :as shortcut2]
             [frontend.components.svg :as svg]
             [frontend.config :as config]
             [frontend.context.i18n :refer [t]]
@@ -23,7 +25,6 @@
             [frontend.mobile.util :as mobile-util]
             [frontend.modules.instrumentation.core :as instrument]
             [frontend.modules.shortcut.data-helper :as shortcut-helper]
-            [frontend.components.shortcut2 :as shortcut2]
             [frontend.spec.storage :as storage-spec]
             [frontend.state :as state]
             [frontend.storage :as storage]
@@ -1019,8 +1020,9 @@
          [:label.flex.font-medium.leading-5.self-start.mt-1
           (ui/icon  (if logged-in? "lock-open" "lock") {:class "mr-1"}) (t :settings-page/beta-features)]]
         [:div.flex.flex-col.gap-4
-         {:class (when-not user-handler/alpha-or-beta-user? "opacity-50 pointer-events-none cursor-not-allowed")}
-         (sync-switcher-row enable-sync?)
+         {:class (when-not (user-handler/alpha-or-beta-user?) "opacity-50 pointer-events-none cursor-not-allowed")}
+         (when cconfig/ENABLE-FILE-SYNC-FEATURE
+           (sync-switcher-row enable-sync?))
          (when enable-sync?
            (sync-diff-merge-switcher-row enable-sync-diff-merge?))
          [:div.text-sm

+ 33 - 30
src/main/frontend/handler/events.cljs

@@ -89,30 +89,31 @@
     (file-sync-handler/set-sync-enabled! true)))
 
 (defmethod handle :user/fetch-info-and-graphs [[_]]
-  (state/set-state! [:ui/loading? :login] false)
   (async/go
-    (let [result (async/<! (sync/<user-info sync/remoteapi))]
-      (cond
-        (instance? ExceptionInfo result)
-        nil
-        (map? result)
-        (do
-          (state/set-user-info! result)
-          (when-let [uid (user-handler/user-uuid)]
-            (sentry-event/set-user! uid))
-          (let [status (if (user-handler/alpha-or-beta-user?) :welcome :unavailable)]
-            (when (and (= status :welcome) (user-handler/logged-in?))
-              (enable-beta-features!)
-              (async/<! (file-sync-handler/load-session-graphs))
-              (p/let [repos (repo-handler/refresh-repos!)]
-                (when-let [repo (state/get-current-repo)]
-                  (when (some #(and (= (:url %) repo)
-                                    (vector? (:sync-meta %))
-                                    (util/uuid-string? (first (:sync-meta %)))
-                                    (util/uuid-string? (second (:sync-meta %)))) repos)
-                    (sync/<sync-start)))))
-            (ui-handler/re-render-root!)
-            (file-sync/maybe-onboarding-show status)))))))
+    (when (state/enable-sync?)
+      (state/set-state! [:ui/loading? :login] false)
+      (let [result (async/<! (sync/<user-info sync/remoteapi))]
+        (cond
+          (instance? ExceptionInfo result)
+          nil
+          (map? result)
+          (do
+            (state/set-user-info! result)
+            (when-let [uid (user-handler/user-uuid)]
+              (sentry-event/set-user! uid))
+            (let [status (if (user-handler/alpha-or-beta-user?) :welcome :unavailable)]
+              (when (and (= status :welcome) (user-handler/logged-in?))
+                (enable-beta-features!)
+                (async/<! (file-sync-handler/load-session-graphs))
+                (p/let [repos (repo-handler/refresh-repos!)]
+                  (when-let [repo (state/get-current-repo)]
+                    (when (some #(and (= (:url %) repo)
+                                      (vector? (:sync-meta %))
+                                      (util/uuid-string? (first (:sync-meta %)))
+                                      (util/uuid-string? (second (:sync-meta %)))) repos)
+                      (sync/<sync-start)))))
+              (ui-handler/re-render-root!)
+              (file-sync/maybe-onboarding-show status))))))))
 
 (defmethod handle :user/logout [[_]]
   (file-sync-handler/reset-session-graphs)
@@ -749,15 +750,17 @@
            :close-backdrop? false} opts)))
 
 (defmethod handle :file-sync/onboarding-tip [[_ type opts]]
-  (let [type (keyword type)]
-    (state/set-modal!
-     (file-sync/make-onboarding-panel type)
-     (merge {:close-btn?      false
-             :center?         true
-             :close-backdrop? (not= type :welcome)} opts))))
+  (when (state/enable-sync?)
+    (let [type (keyword type)]
+      (state/set-modal!
+       (file-sync/make-onboarding-panel type)
+       (merge {:close-btn?      false
+               :center?         true
+               :close-backdrop? (not= type :welcome)} opts)))))
 
 (defmethod handle :file-sync/maybe-onboarding-show [[_ type]]
-  (file-sync/maybe-onboarding-show type))
+  (when (state/enable-sync?)
+    (file-sync/maybe-onboarding-show type)))
 
 (defmethod handle :file-sync/storage-exceed-limit [[_]]
   (notification/show! "file sync storage exceed limit" :warning false)