Browse Source

fix: don't show delete local graph if it's already deleted

Tienson Qin 5 months ago
parent
commit
047dd05400
2 changed files with 22 additions and 19 deletions
  1. 18 17
      src/main/frontend/components/repo.cljs
  2. 4 2
      src/main/mobile/components/popup.cljs

+ 18 - 17
src/main/frontend/components/repo.cljs

@@ -107,23 +107,24 @@
             (ui/icon "dots" {:size 15})))
           (shui/dropdown-menu-content
            {:align "end"}
-           (shui/dropdown-menu-item
-            {:key "delete-locally"
-             :class "delete-local-graph-menu-item"
-             :on-click (fn []
-                         (let [prompt-str (if db-based?
-                                            (str "Are you sure you want to permanently delete the graph \"" graph-name "\" from Logseq?")
-                                            (str "Are you sure you want to unlink the graph \"" url "\" from local folder?"))]
-                           (-> (shui/dialog-confirm!
-                                [:p.font-medium.-my-4 prompt-str
-                                 [:span.my-2.flex.font-normal.opacity-75
-                                  (if db-based?
-                                    [:small "⚠️ Notice that we can't recover this graph after being deleted. Make sure you have backups before deleting it."]
-                                    [:small "⚠️ It won't remove your local files!"])]])
-                               (p/then (fn []
-                                         (repo-handler/remove-repo! repo)
-                                         (state/pub-event! [:graph/unlinked repo (state/get-current-repo)]))))))}
-            "Delete local graph")
+           (when root
+             (shui/dropdown-menu-item
+              {:key "delete-locally"
+               :class "delete-local-graph-menu-item"
+               :on-click (fn []
+                           (let [prompt-str (if db-based?
+                                              (str "Are you sure you want to permanently delete the graph \"" graph-name "\" from Logseq?")
+                                              (str "Are you sure you want to unlink the graph \"" url "\" from local folder?"))]
+                             (-> (shui/dialog-confirm!
+                                  [:p.font-medium.-my-4 prompt-str
+                                   [:span.my-2.flex.font-normal.opacity-75
+                                    (if db-based?
+                                      [:small "⚠️ Notice that we can't recover this graph after being deleted. Make sure you have backups before deleting it."]
+                                      [:small "⚠️ It won't remove your local files!"])]])
+                                 (p/then (fn []
+                                           (repo-handler/remove-repo! repo)
+                                           (state/pub-event! [:graph/unlinked repo (state/get-current-repo)]))))))}
+              "Delete local graph"))
            (when (and remote? (or (and db-based? manager?) (not db-based?)))
              (shui/dropdown-menu-item
               {:key "delete-remotely"

+ 4 - 2
src/main/mobile/components/popup.cljs

@@ -81,7 +81,9 @@
 (rum/defc popup < rum/reactive
   []
   (let [{:keys [open? content-fn opts]} (rum/react mobile-state/*popup-data)
-        initial-breakpoint (if (= (:id opts) :ls-quick-add) 1 0.75)]
+        [initial-breakpoint breakpoints] (if (= (:id opts) :ls-quick-add)
+                                           [1 #js [0 1]]
+                                           [0.75 #js [0 0.75 1]])]
     (when open?
       (if (= :ls-quick-add (:id opts))
         (when-let [add-page (ldb/get-built-in-page (db/get-db) common-config/quick-add-page-name)]
@@ -98,7 +100,7 @@
      (merge
       {:isOpen (boolean open?)
        :initialBreakpoint initial-breakpoint
-       :breakpoints #js [0 0.75 1]
+       :breakpoints breakpoints
        :onDidDismiss (fn [] (mobile-state/set-popup! nil))
        :expand "block"}
       (:modal-props opts))