Browse Source

enhance(ios): add sync progress

Andelf 3 năm trước cách đây
mục cha
commit
ad4fec8ce7

+ 3 - 3
src/main/frontend/components/file_sync.cljs

@@ -323,7 +323,7 @@
   [_state]
   (let [_                       (state/sub :auth/id-token)
         online?                 (state/sub :network/online?)
-        enabled-progress-panel? (util/electron?)
+        enabled-progress-panel? (or (util/electron?) (mobile-util/native-ios?))
         current-repo            (state/get-current-repo)
         creating-remote-graph?  (state/sub [:ui/loading? :graph/create-remote?])
         current-graph-id        (state/sub-current-file-sync-graph-uuid)
@@ -428,7 +428,7 @@
             synced-file-graph?
             (concat
              (if (and no-active-files? idle?)
-               [(when-not (util/electron?)
+               [(when-not (or (util/electron?) (mobile-util/native-ios?))
                   {:item     [:div.flex.justify-center.w-full.py-2
                               [:span.opacity-60 "Everything is synced!"]]
                    :as-link? false})]
@@ -503,7 +503,7 @@
           ;; options
           {:outer-header
            [:<>
-            (when (util/electron?)
+            (when (or (util/electron?) (mobile-util/native-ios?))
               (indicator-progress-pane
                sync-state sync-progress
                {:idle?            idle?

+ 7 - 1
src/main/frontend/mobile/core.cljs

@@ -37,9 +37,15 @@
 
   (mobile-util/check-ios-zoomed-display)
 
+  ;; keep this the same logic as src/main/electron/listener.cljs
   (.addListener mobile-util/file-sync "debug"
                 (fn [event]
-                  (js/console.log "🔄" event))))
+                  (js/console.log "🔄" event)
+                  (let [event (js->clj event :keywordize-keys true)
+                        payload (:data event)]
+                    (when (or (= (:event event) "download:progress")
+                              (= (:event event) "upload:progress"))
+                      (state/set-state! [:file-sync/graph-state (:graphUUID payload) :file-sync/progress (:file payload)] payload))))))
 
 (defn- android-init
   "Initialize Android-specified event listeners"