Browse Source

enhance(android): add sync progress

Andelf 3 years ago
parent
commit
503e33f614
4 changed files with 29 additions and 26 deletions
  1. 1 1
      package.json
  2. 14 20
      src/main/frontend/components/file_sync.cljs
  3. 10 1
      src/main/frontend/mobile/core.cljs
  4. 4 4
      yarn.lock

+ 1 - 1
package.json

@@ -89,7 +89,7 @@
         "@capacitor/status-bar": "^4.0.0",
         "@excalidraw/excalidraw": "0.12.0",
         "@kanru/rage-wasm": "^0.3.0",
-        "@logseq/capacitor-file-sync": "0.0.11",
+        "@logseq/capacitor-file-sync": "0.0.12",
         "@logseq/react-tweet-embed": "1.3.1-1",
         "@sentry/react": "^6.18.2",
         "@sentry/tracing": "^6.18.2",

+ 14 - 20
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? (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)))))

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

@@ -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.))

+ 4 - 4
yarn.lock

@@ -482,10 +482,10 @@
   resolved "https://registry.yarnpkg.com/@kanru/rage-wasm/-/rage-wasm-0.3.0.tgz#de96b1fda1f781ff401d43b50d0f95b7338c4399"
   integrity sha512-2LMRS27nNJPqFNpRQL7kXG0kgBeIPo63KM6u0Xu6Es5XIS7LP4MFtdHkCg8Pt7IhMM7GuOa2YnzAZgKBxE1lcw==
 
-"@logseq/[email protected]1":
-  version "0.0.11"
-  resolved "https://registry.yarnpkg.com/@logseq/capacitor-file-sync/-/capacitor-file-sync-0.0.11.tgz#aa84f320d73c292d8dd9e483e0ccf73baa2e021b"
-  integrity sha512-ZCV/2fp8iPpShk+rk+6aH3aFZID7BKhSlyw/f4fcSCapbh6im638GR2fi9RPRc1eg+0vbtrx6UzG7Vbw+Kz2aQ==
+"@logseq/[email protected]2":
+  version "0.0.12"
+  resolved "https://registry.yarnpkg.com/@logseq/capacitor-file-sync/-/capacitor-file-sync-0.0.12.tgz#26ab202d9925acaad42d38c58708c3adae39d79f"
+  integrity sha512-qYCvBI6XvaLbqYPxyqD02lRFoJ2MlOHX2Bp5+rDb1SGgfJW0kIstCTZ2B7Sb8tng7ZN1b6kb9fvLRGD2zviuMQ==
 
 "@logseq/[email protected]":
   version "1.3.1-1"