enhance(android): add sync progress

This commit is contained in:
Andelf
2022-10-11 15:24:04 +08:00
committed by Tienson Qin
parent 29cee9c1dc
commit 503e33f614
4 changed files with 29 additions and 26 deletions

View File

@@ -323,7 +323,7 @@
[_state]
(let [_ (state/sub :auth/id-token)
online? (state/sub :network/online?)
enabled-progress-panel? (or (util/electron?) (mobile-util/native-ios?))
enabled-progress-panel? true
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)
@@ -387,7 +387,7 @@
(if (= (:url r) current-repo)
(dissoc r :GraphUUID :GraphName :remote?)
r))
(state/get-repos)))
(state/get-repos)))
(create-remote-graph-fn))
(second @graphs-txid) ; sync not started yet
@@ -427,12 +427,7 @@
(cond-> []
synced-file-graph?
(concat
(if (and no-active-files? idle?)
[(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})]
(when-not (and no-active-files? idle?)
(cond
need-password?
[{:title [:div.file-item
@@ -503,17 +498,16 @@
;; options
{:outer-header
[:<>
(when (or (util/electron?) (mobile-util/native-ios?))
(indicator-progress-pane
sync-state sync-progress
{:idle? idle?
:syncing? syncing?
:need-password? need-password?
:full-sync? full-syncing?
:online? online?
:queuing? queuing?
:no-active-files? no-active-files?
:history-files? (seq history-files)}))
(indicator-progress-pane
sync-state sync-progress
{:idle? idle?
:syncing? syncing?
:need-password? need-password?
:full-sync? full-syncing?
:online? online?
:queuing? queuing?
:no-active-files? no-active-files?
:history-files? (seq history-files)})
(when (and
(not enabled-progress-panel?)
@@ -867,4 +861,4 @@
(state/pub-event! [:file-sync/onboarding-tip type])
(state/set-state! [:file-sync/onboarding-state (keyword type)] true)))
(catch :default e
(js/console.warn "[onboarding SKIP] " (name type) e)))))
(js/console.warn "[onboarding SKIP] " (name type) e)))))

View File

@@ -47,6 +47,8 @@
(= (: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"
[]
@@ -72,7 +74,14 @@
(js/window.history.back)))))
(.addEventListener js/window "sendIntentReceived"
#(intent/handle-received)))
#(intent/handle-received))
(.addListener mobile-util/file-sync "progress"
(fn [event]
(js/console.log "🔄" event)
(let [event (js->clj event :keywordize-keys true)]
(state/set-state! [:file-sync/graph-state (:graphUUID event) :file-sync/progress (:file event)] event)))))
(defn- app-state-change-handler
[^js state]
(println :debug :app-state-change-handler state (js/Date.))