From ad4fec8ce7f59e7b156347fcbf85bef913df79ca Mon Sep 17 00:00:00 2001 From: Andelf Date: Sun, 9 Oct 2022 14:38:55 +0800 Subject: [PATCH] enhance(ios): add sync progress --- src/main/frontend/components/file_sync.cljs | 6 +++--- src/main/frontend/mobile/core.cljs | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/frontend/components/file_sync.cljs b/src/main/frontend/components/file_sync.cljs index df4dd10688..7b8946ea9d 100644 --- a/src/main/frontend/components/file_sync.cljs +++ b/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? diff --git a/src/main/frontend/mobile/core.cljs b/src/main/frontend/mobile/core.cljs index c608bd5481..2bb072195e 100644 --- a/src/main/frontend/mobile/core.cljs +++ b/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"