浏览代码

fix: cloud icon is not shown when restarting the app

Tienson Qin 3 年之前
父节点
当前提交
e008a38540

+ 0 - 1
shadow-cljs.edn

@@ -32,7 +32,6 @@
                            :warnings           {:fn-deprecated false
                                                 :redef false}}
         :closure-defines  {goog.debug.LOGGING_ENABLED       true
-                           frontend.config/ENABLE-FILE-SYNC #shadow/env ["ENABLE_FILE_SYNC" :as :bool :default false]
                            frontend.config/ENABLE-PLUGINS   #shadow/env ["ENABLE_PLUGINS"   :as :bool :default true]
                            frontend.config/ENABLE-FILE-SYNC-PRODUCTION #shadow/env ["ENABLE_FILE_SYNC_PRODUCTION" :as :bool :default false]}
 

+ 2 - 1
src/main/electron/listener.cljs

@@ -5,6 +5,7 @@
             [frontend.handler.route :as route-handler]
             [frontend.handler.editor :as editor-handler]
             [frontend.handler.ui :as ui-handler]
+            [frontend.handler.file-sync :as file-sync-handler]
             [frontend.config :as config]
             [clojure.string :as string]
             [cljs-bean.core :as bean]
@@ -45,7 +46,7 @@
                      (fn [data]
                        (let [{:keys [type payload]} (bean/->clj data)]
                          (watcher-handler/handle-changed! type payload)
-                         (when config/enable-file-sync?
+                         (when (file-sync-handler/enable-sync?)
                            (sync/file-watch-handler type payload)))))
 
   (js/window.apis.on "notification"

+ 0 - 1
src/main/frontend/components/file_sync.cljs

@@ -230,7 +230,6 @@
       [:div.cp__file-sync-indicator
        (when (and (not config/publishing?)
                   (user-handler/logged-in?))
-
          (ui/dropdown-with-links
           (fn [{:keys [toggle-fn]}]
             (if (not off?)

+ 14 - 10
src/main/frontend/components/header.cljs

@@ -34,10 +34,12 @@
 (rum/defc login < rum/reactive
   []
   (let [_ (state/sub :auth/id-token)
-        loading? (state/sub [:ui/loading? :login])]
+        loading? (state/sub [:ui/loading? :login])
+        sync-enabled? (file-sync-handler/enable-sync?)
+        logged? (user-handler/logged-in?)]
     (when-not (or config/publishing?
-                  (user-handler/logged-in?)
-                  (not (state/enable-sync?)))
+                  logged?
+                  (not sync-enabled?))
       [:a.button.text-sm.font-medium.block {:on-click #(js/window.open config/LOGIN-URL)}
        [:span (t :login)]
        (when loading?
@@ -155,7 +157,8 @@
                                                  (state/set-left-sidebar-open!
                                                   (not (:ui/left-sidebar-open? @state/state))))})
         custom-home-page? (and (state/custom-home-page?)
-                               (= (state/sub-default-home-page) (state/get-current-page)))]
+                               (= (state/sub-default-home-page) (state/get-current-page)))
+        sync-enabled? (file-sync-handler/enable-sync?)]
     [:div.cp__header#head
      {:class           (util/classnames [{:electron-mac   electron-mac?
                                           :native-ios     (mobile-util/native-ios?)
@@ -187,17 +190,18 @@
              (ui/icon "chevron-left" {:style {:fontSize 25}})])))]
 
      [:div.r.flex
-      (when (and (not file-sync-handler/hiding-login&file-sync)
-                 current-repo
-                 (not (config/demo-graph? current-repo))
-                 (user-handler/alpha-user?))
-        (fs-sync/indicator))
+      (do
+        (when (and sync-enabled?
+                  current-repo
+                  (not (config/demo-graph? current-repo))
+                  (user-handler/alpha-user?))
+         (fs-sync/indicator)))
 
       (when (and (not= (state/get-current-route) :home)
                  (not custom-home-page?))
         (home-button))
 
-      (when-not file-sync-handler/hiding-login&file-sync
+      (when sync-enabled?
         (login))
 
       (when plugin-handler/lsp-enabled?

+ 1 - 1
src/main/frontend/components/page_menu.cljs

@@ -74,7 +74,7 @@
           file-path (when (util/electron?) (page-handler/get-page-file-path))
           _ (state/sub :auth/id-token)
           file-sync-graph-uuid (and (user-handler/logged-in?)
-                                    (not file-sync-handler/hiding-login&file-sync)
+                                    (file-sync-handler/enable-sync?)
                                     (file-sync-handler/get-current-graph-uuid))]
       (when (and page (not block?))
         (->>

+ 0 - 9
src/main/frontend/config.cljs

@@ -21,13 +21,6 @@
 
 (goog-define ENABLE-FILE-SYNC-PRODUCTION false)
 
-;; prod env
-;; (goog-define FILE-SYNC-PROD? true)
-;; (goog-define LOGIN-URL
-;;              "https://logseq-prod.auth.us-east-1.amazoncognito.com/login?client_id=3c7np6bjtb4r1k1bi9i049ops5&response_type=code&scope=email+openid+phone&redirect_uri=logseq%3A%2F%2Fauth-callback")
-;; (goog-define API-DOMAIN "api-prod.logseq.com")
-;; (goog-define WS-URL "wss://b2rp13onu2.execute-api.us-east-1.amazonaws.com/production?graphuuid=%s")
-
 (if ENABLE-FILE-SYNC-PRODUCTION
   (do (def FILE-SYNC-PROD? true)
       (def LOGIN-URL
@@ -42,8 +35,6 @@
       (def WS-URL "wss://ws-dev.logseq.com/file-sync?graphuuid=%s")))
 
 ;; feature flags
-(goog-define ENABLE-FILE-SYNC false)
-(defonce enable-file-sync? (or ENABLE-FILE-SYNC dev?)) ;; always enable file-sync when dev
 
 (goog-define ENABLE-PLUGINS true)
 (defonce enable-plugins? ENABLE-PLUGINS)

+ 1 - 1
src/main/frontend/handler/events.cljs

@@ -515,7 +515,7 @@
         payload (-> event
                     (js->clj :keywordize-keys true))]
     (fs-watcher/handle-changed! type payload)
-    (when config/enable-file-sync?
+    (when (file-sync-handler/enable-sync?)
      (sync/file-watch-handler type payload))))
 
 (defmethod handle :rebuild-slash-commands-list [[_]]

+ 6 - 2
src/main/frontend/handler/file_sync.cljs

@@ -14,9 +14,13 @@
 
 (def *beta-unavailable? (volatile! false))
 
-(def hiding-login&file-sync (not config/enable-file-sync?))
 (def refresh-file-sync-component (atom false))
 
+(defn enable-sync?
+  []
+  (or (state/enable-sync?)
+      config/dev?))
+
 (defn current-graph-sync-on?
   []
   (when-let [sync-state (state/sub [:file-sync/sync-state (state/get-current-repo)])]
@@ -196,4 +200,4 @@
 
 (defn reset-user-state! []
   (vreset! *beta-unavailable? false)
-  (state/set-state! :file-sync/onboarding-state nil))
+  (state/set-state! :file-sync/onboarding-state nil))

+ 1 - 1
src/main/frontend/state.cljs

@@ -402,7 +402,7 @@
 
 (defn user-groups
   []
-  (set (get-in @state [:user/info :UserGroups])))
+  (set (sub [:user/info :UserGroups])))
 
 (defn enable-sync?
   []