fix: unlink wrong graphs

This commit is contained in:
Tienson Qin
2022-11-07 23:44:53 +08:00
parent d40bfa2fbe
commit 5a66bf8fb9
4 changed files with 14 additions and 9 deletions

View File

@@ -85,10 +85,11 @@
(file-sync/load-session-graphs)
(state/set-state! [:ui/loading? :remove/remote-graph GraphUUID] false)))}))]
(state/set-modal! (confirm-fn)))
(do
(let [current-repo (state/get-current-repo)]
(repo-handler/remove-repo! repo)
(file-sync/load-session-graphs)
(state/pub-event! [:graph/unlinked]))))}
(state/pub-event! [:graph/unlinked repo current-repo])
(when only-cloud?
(file-sync/load-session-graphs)))))}
(if only-cloud? "Remove" "Unlink")])])]]))
(rum/defc repos < rum/reactive

View File

@@ -116,9 +116,9 @@
(repo-handler/refresh-repos!)
(file-sync-restart!))
(defmethod handle :graph/unlinked [_]
(repo-handler/refresh-repos!)
(file-sync-restart!))
(defmethod handle :graph/unlinked [repo current-repo]
(when (= (:url repo) current-repo)
(file-sync-restart!)))
(defmethod handle :graph/refresh [_]
(repo-handler/refresh-repos!))

View File

@@ -341,13 +341,14 @@
(defn remove-repo!
[{:keys [url] :as repo}]
(let [delete-db-f (fn []
(let [graph-exists? (db/get-db url)]
(let [graph-exists? (db/get-db url)
current-repo (state/get-current-repo)]
(db/remove-conn! url)
(db-persist/delete-graph! url)
(search/remove-db! url)
(state/delete-repo! repo)
(when graph-exists? (ipc/ipc "graphUnlinked" repo))
(when (= (state/get-current-repo) url)
(when (= current-repo url)
(state/set-current-repo! (:url (first (state/get-repos)))))))]
(when (or (config/local-db? url) (= url "local"))
(-> (p/let [_ (idb/clear-local-db! url)] ; clear file handles

View File

@@ -762,7 +762,10 @@ Similar to re-frame subscriptions"
(swap! state update-in [:me :repos]
(fn [repos]
(->> (remove #(or (= (:url repo) (:url %))
(= (:GraphUUID repo) (:GraphUUID %))) repos)
(and
(:GraphUUID repo)
(:GraphUUID %)
(= (:GraphUUID repo) (:GraphUUID %)))) repos)
(util/distinct-by :url)))))
(defn set-timestamp-block!