🐛 Fix 'Reset override' menu option still present after remove library

This commit is contained in:
Pablo Alba 2023-11-03 14:10:32 +01:00 committed by Andrés Moya
parent d0fa58c66c
commit b07e9bdd37

View file

@ -318,10 +318,9 @@
(filter #(nil? (find-component %))) (filter #(nil? (find-component %)))
(filter #(local-or-exists %))) (filter #(local-or-exists %)))
touched-not-dangling (filter #(and (cph/component-touched? objects (:id %))
touched-components (filter #(cph/component-touched? objects (:id %)) copies) (find-component %)) copies)
can-reset-overrides? (or (not components-v2) (seq touched-not-dangling))
can-reset-overrides? (or (not components-v2) (seq touched-components))
;; For when it's only one shape ;; For when it's only one shape
@ -337,16 +336,22 @@
lacks-annotation? (nil? (:annotation component)) lacks-annotation? (nil? (:annotation component))
is-dangling? (nil? component) is-dangling? (nil? component)
can-update-main? (or (not components-v2) can-show-component? (and (not multi)
(and
(not main-instance?) (not main-instance?)
(cph/component-touched? objects (:id shape)))) (not is-dangling?))
can-update-main? (and (not multi)
(not is-dangling?)
(or (not components-v2)
(and (not main-instance?)
(cph/component-touched? objects (:id shape)))))
do-detach-component do-detach-component
#(st/emit! (dwl/detach-components (map :id copies))) #(st/emit! (dwl/detach-components (map :id copies)))
do-reset-component do-reset-component
#(st/emit! (dwl/reset-components (map :id touched-components))) #(st/emit! (dwl/reset-components (map :id touched-not-dangling)))
do-restore-component do-restore-component
#(let [;; Extract a map of component-id -> component-file in order to avoid duplicates #(let [;; Extract a map of component-id -> component-file in order to avoid duplicates
@ -415,10 +420,10 @@
(when (and (seq restorable-copies) components-v2) (when (and (seq restorable-copies) components-v2)
{:msg "workspace.shape.menu.restore-main" {:msg "workspace.shape.menu.restore-main"
:action do-restore-component}) :action do-restore-component})
(when (and (not multi) (not main-instance?) (not is-dangling?)) (when can-show-component?
{:msg "workspace.shape.menu.show-main" {:msg "workspace.shape.menu.show-main"
:action do-show-component}) :action do-show-component})
(when (and (not multi) can-update-main? (not is-dangling?)) (when can-update-main?
{:msg "workspace.shape.menu.update-main" {:msg "workspace.shape.menu.update-main"
:action do-update-component})]] :action do-update-component})]]
(filter (complement nil?) menu-entries))) (filter (complement nil?) menu-entries)))