step 3 :file-sync/progress

This commit is contained in:
Tienson Qin
2022-09-29 22:31:21 +08:00
parent 7eff58625f
commit 09e7715e2f
5 changed files with 24 additions and 21 deletions

View File

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