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