Tienson Qin 3 лет назад
Родитель
Сommit
5a66bf8fb9

+ 4 - 3
src/main/frontend/components/repo.cljs

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

+ 3 - 3
src/main/frontend/handler/events.cljs

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

+ 3 - 2
src/main/frontend/handler/repo.cljs

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

+ 4 - 1
src/main/frontend/state.cljs

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