Selaa lähdekoodia

move icloud-sync to mobile-util

leizhe 3 vuotta sitten
vanhempi
sitoutus
ca755f2605
2 muutettua tiedostoa jossa 10 lisäystä ja 10 poistoa
  1. 3 10
      src/main/frontend/handler.cljs
  2. 7 0
      src/main/frontend/mobile/util.cljs

+ 3 - 10
src/main/frontend/handler.cljs

@@ -58,14 +58,6 @@
     (f)
     (js/setInterval f 5000)))
 
-(defn- icloud-sync!
-  []
-  (let [f (fn []
-            (when (state/get-current-repo)
-              (.downloadFilesFromiCloud mobile-util/download-icloud-files)))]
-    (f)
-    (js/setInterval f 300000)))
-
 (defn- instrument!
   []
   (let [total (srs/get-srs-cards-total)]
@@ -138,8 +130,9 @@
                                  (js/console.error "Failed to request GitHub app tokens."))))
 
                             (watch-for-date!)
-                            (when (mobile-util/native-ios?)
-                              (icloud-sync!))
+                            (when (and (state/get-current-repo)
+                                       (mobile-util/native-ios?))
+                              (mobile-util/icloud-sync!))
                             (file-handler/watch-for-current-graph-dir!)))
                          (p/catch (fn [error]
                                     (log/error :exception error))))))

+ 7 - 0
src/main/frontend/mobile/util.cljs

@@ -122,3 +122,10 @@
     (if (and model landscape?)
       20
       (:statusbar (model @idevice-info)))))
+
+(defn icloud-sync!
+  []
+  (let [f (fn []
+            (.downloadFilesFromiCloud download-icloud-files))]
+    (f)
+    (js/setInterval f 300000)))