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

This commit is contained in:
Tienson Qin
2025-07-08 00:58:13 +08:00
parent 6d91359414
commit 047dd05400
2 changed files with 22 additions and 19 deletions

View File

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

View File

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