fix: remote graphs state when create/delete a remote graph

This commit is contained in:
Tienson Qin
2022-11-08 00:48:38 +08:00
parent 5a66bf8fb9
commit 20e1e77362
7 changed files with 56 additions and 45 deletions

View File

@@ -711,7 +711,7 @@ Similar to re-frame subscriptions"
(when-not (mobile-util/native-platform?)
"local")))
(defn get-remote-repos
(defn get-remote-graphs
[]
(get-in @state [:file-sync/remote-graphs :graphs]))
@@ -720,6 +720,22 @@ Similar to re-frame subscriptions"
(when-let [graphs (seq (get-in @state [:file-sync/remote-graphs :graphs]))]
(some #(when (= (:GraphUUID %) (str uuid)) %) graphs)))
(defn delete-remote-graph!
[repo]
(swap! state update-in [:file-sync/remote-graphs :graphs]
(fn [repos]
(remove #(and
(:GraphUUID repo)
(:GraphUUID %)
(= (:GraphUUID repo) (:GraphUUID %))) repos))))
(defn add-remote-graph!
[repo]
(swap! state update-in [:file-sync/remote-graphs :graphs]
(fn [repos]
(->> (conj repos repo)
(distinct)))))
(defn get-repos
[]
(get-in @state [:me :repos]))