Browse Source

fix: click remote rtc graph should download it

Tienson Qin 1 year ago
parent
commit
ec3506f8ad
1 changed files with 13 additions and 4 deletions
  1. 13 4
      src/main/frontend/components/repo.cljs

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

@@ -50,9 +50,18 @@
         :let [only-cloud? (and remote? (nil? root))
               db-based? (config/db-based-graph? url)]]
     [:div.flex.justify-between.mb-4.items-center {:key (or url GraphUUID)}
-     (normalized-graph-label repo #(if only-cloud?
-                                     (state/pub-event! [:graph/pull-down-remote-graph repo])
-                                     (state/pub-event! [:graph/switch url])))
+     (normalized-graph-label repo
+                             (fn []
+                               (when-not (state/sub :rtc/downloading-graph-uuid)
+                                 (cond
+                                   root ; exists locally
+                                   (state/pub-event! [:graph/switch url])
+
+                                   (and db-based? remote?)
+                                   (state/pub-event! [:rtc/download-remote-graph GraphName GraphUUID])
+
+                                   :else
+                                   (state/pub-event! [:graph/pull-down-remote-graph repo])))))
 
      [:div.controls
       [:div.flex.flex-row.items-center
@@ -107,7 +116,7 @@
                                  (if has-prompt?
                                    (state/set-modal! (confirm-fn))
                                    (unlink-or-remote-fn))))}
-                  (if (or db-based? only-cloud?) "Remove" "Unlink")])]]]))
+                  (if only-cloud? "Remove (server)" "Unlink (local)")])]]]))
 
 (rum/defc repos < rum/reactive
   []