mirror of https://github.com/logseq/logseq
step 3 :file-sync/progress
parent
7eff58625f
commit
09e7715e2f
|
@ -54,8 +54,7 @@
|
||||||
(js/window.apis.on "file-sync-progress"
|
(js/window.apis.on "file-sync-progress"
|
||||||
(fn [data]
|
(fn [data]
|
||||||
(let [payload (bean/->clj data)]
|
(let [payload (bean/->clj data)]
|
||||||
(state/set-state! [:file-sync/progress (:graphUUID payload) (:file payload)] payload)
|
(state/set-state! [:file-sync/graph-state (:graphUUID payload) :file-sync/progress (:file payload)] payload))))
|
||||||
nil)))
|
|
||||||
|
|
||||||
(js/window.apis.on "notification"
|
(js/window.apis.on "notification"
|
||||||
(fn [data]
|
(fn [data]
|
||||||
|
|
|
@ -324,8 +324,11 @@
|
||||||
enabled-progress-panel? (util/electron?)
|
enabled-progress-panel? (util/electron?)
|
||||||
current-repo (state/get-current-repo)
|
current-repo (state/get-current-repo)
|
||||||
creating-remote-graph? (state/sub [:ui/loading? :graph/create-remote?])
|
creating-remote-graph? (state/sub [:ui/loading? :graph/create-remote?])
|
||||||
sync-state (state/get-file-sync-state (state/get-current-file-sync-graph-uuid))
|
current-graph-id (state/get-current-file-sync-graph-uuid)
|
||||||
sync-progress (state/sub [:file-sync/progress (second @fs-sync/graphs-txid)])
|
sync-state (state/get-file-sync-state current-graph-id)
|
||||||
|
sync-progress (state/sub [:file-sync/graph-state
|
||||||
|
current-graph-id
|
||||||
|
:file-sync/progress])
|
||||||
_ (rum/react file-sync-handler/refresh-file-sync-component)
|
_ (rum/react file-sync-handler/refresh-file-sync-component)
|
||||||
synced-file-graph? (file-sync-handler/synced-file-graph? current-repo)
|
synced-file-graph? (file-sync-handler/synced-file-graph? current-repo)
|
||||||
uploading-files (sort-files (:current-local->remote-files sync-state))
|
uploading-files (sort-files (:current-local->remote-files sync-state))
|
||||||
|
|
|
@ -2857,10 +2857,6 @@
|
||||||
(reset! current-sm-graph-uuid graph-uuid)
|
(reset! current-sm-graph-uuid graph-uuid)
|
||||||
(sync-manager user-uuid graph-uuid base-path repo txid *sync-state)))
|
(sync-manager user-uuid graph-uuid base-path repo txid *sync-state)))
|
||||||
|
|
||||||
(defn clear-graph-progress!
|
|
||||||
[graph-uuid]
|
|
||||||
(state/set-state! [:file-sync/progress graph-uuid] {}))
|
|
||||||
|
|
||||||
(defn <sync-stop []
|
(defn <sync-stop []
|
||||||
(go
|
(go
|
||||||
(when-let [sm ^SyncManager (state/get-file-sync-manager (state/get-current-file-sync-graph-uuid))]
|
(when-let [sm ^SyncManager (state/get-file-sync-manager (state/get-current-file-sync-graph-uuid))]
|
||||||
|
@ -2870,9 +2866,7 @@
|
||||||
|
|
||||||
(<! (-stop! sm))
|
(<! (-stop! sm))
|
||||||
|
|
||||||
(println "[SyncManager" (:graph-uuid sm) "]" "stopped")
|
(println "[SyncManager" (:graph-uuid sm) "]" "stopped"))
|
||||||
|
|
||||||
(clear-graph-progress! (:graph-uuid sm)))
|
|
||||||
|
|
||||||
(reset! current-sm-graph-uuid nil)))
|
(reset! current-sm-graph-uuid nil)))
|
||||||
|
|
||||||
|
@ -2948,7 +2942,6 @@
|
||||||
(try
|
(try
|
||||||
(when-not (get @*sync-starting? graph-uuid)
|
(when-not (get @*sync-starting? graph-uuid)
|
||||||
(swap! *sync-starting? assoc graph-uuid true)
|
(swap! *sync-starting? assoc graph-uuid true)
|
||||||
(clear-graph-progress! graph-uuid)
|
|
||||||
|
|
||||||
(when-some [sm (sync-manager-singleton current-user-uuid graph-uuid
|
(when-some [sm (sync-manager-singleton current-user-uuid graph-uuid
|
||||||
(config/get-repo-dir repo) repo
|
(config/get-repo-dir repo) repo
|
||||||
|
|
|
@ -195,7 +195,7 @@
|
||||||
(case event
|
(case event
|
||||||
(list :finished-local->remote :finished-remote->local)
|
(list :finished-local->remote :finished-remote->local)
|
||||||
(do
|
(do
|
||||||
(sync/clear-graph-progress! (second @sync/graphs-txid))
|
(state/clear-file-sync-progress! (state/get-current-file-sync-graph-uuid))
|
||||||
(state/set-state! :file-sync/start {})
|
(state/set-state! :file-sync/start {})
|
||||||
(state/set-state! [:file-sync/last-synced-at (state/get-current-repo)]
|
(state/set-state! [:file-sync/last-synced-at (state/get-current-repo)]
|
||||||
(:epoch data)))
|
(:epoch data)))
|
||||||
|
|
|
@ -236,15 +236,15 @@
|
||||||
:file-sync/onboarding-state (or (storage/get :file-sync/onboarding-state)
|
:file-sync/onboarding-state (or (storage/get :file-sync/onboarding-state)
|
||||||
{:welcome false})
|
{:welcome false})
|
||||||
:file-sync/remote-graphs {:loading false :graphs nil}
|
:file-sync/remote-graphs {:loading false :graphs nil}
|
||||||
|
:file-sync/set-remote-graph-password-result {}
|
||||||
|
|
||||||
;; graph-uuid -> [:current-graph-uuid :file-sync/sync-manager :file-sync/sync-state]
|
;; graph-uuid -> [:current-graph-uuid :file-sync/sync-manager :file-sync/sync-state]
|
||||||
:file-sync/graph-state {}
|
:file-sync/graph-state {:current-graph-uuid nil
|
||||||
|
:file-sync/sync-manager nil
|
||||||
|
:file-sync/sync-state nil
|
||||||
|
;; {file-path -> payload}
|
||||||
|
:file-sync/progress nil}
|
||||||
|
|
||||||
:file-sync/sync-uploading-files nil
|
|
||||||
:file-sync/sync-downloading-files nil
|
|
||||||
:file-sync/set-remote-graph-password-result {}
|
|
||||||
;; graph-uuid -> {file-path -> payload}
|
|
||||||
:file-sync/progress {}
|
|
||||||
:file-sync/start {}
|
:file-sync/start {}
|
||||||
;; graph -> epoch
|
;; graph -> epoch
|
||||||
:file-sync/last-synced-at {}
|
:file-sync/last-synced-at {}
|
||||||
|
@ -629,13 +629,15 @@ Similar to re-frame subscriptions"
|
||||||
[path value]
|
[path value]
|
||||||
(if (vector? path)
|
(if (vector? path)
|
||||||
(swap! state assoc-in path value)
|
(swap! state assoc-in path value)
|
||||||
(swap! state assoc path value)))
|
(swap! state assoc path value))
|
||||||
|
nil)
|
||||||
|
|
||||||
(defn update-state!
|
(defn update-state!
|
||||||
[path f]
|
[path f]
|
||||||
(if (vector? path)
|
(if (vector? path)
|
||||||
(swap! state update-in path f)
|
(swap! state update-in path f)
|
||||||
(swap! state update path f)))
|
(swap! state update path f))
|
||||||
|
nil)
|
||||||
|
|
||||||
;; State getters and setters
|
;; State getters and setters
|
||||||
;; =========================
|
;; =========================
|
||||||
|
@ -1772,6 +1774,12 @@ Similar to re-frame subscriptions"
|
||||||
(defn clear-file-sync-state! [graph-uuid]
|
(defn clear-file-sync-state! [graph-uuid]
|
||||||
(set-state! [:file-sync/graph-state graph-uuid] nil))
|
(set-state! [:file-sync/graph-state graph-uuid] nil))
|
||||||
|
|
||||||
|
(defn clear-file-sync-progress! [graph-uuid]
|
||||||
|
(set-state! [:file-sync/graph-state
|
||||||
|
graph-uuid
|
||||||
|
:file-sync/progress]
|
||||||
|
nil))
|
||||||
|
|
||||||
(defn set-file-sync-state [graph-uuid v]
|
(defn set-file-sync-state [graph-uuid v]
|
||||||
(when v (s/assert :frontend.fs.sync/sync-state v))
|
(when v (s/assert :frontend.fs.sync/sync-state v))
|
||||||
(set-state! [:file-sync/graph-state graph-uuid :file-sync/sync-state] v))
|
(set-state! [:file-sync/graph-state graph-uuid :file-sync/sync-state] v))
|
||||||
|
|
Loading…
Reference in New Issue