🐛 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 #(local-or-exists %)))
touched-components (filter #(cph/component-touched? objects (:id %)) copies)
can-reset-overrides? (or (not components-v2) (seq touched-components))
touched-not-dangling (filter #(and (cph/component-touched? objects (:id %))
(find-component %)) copies)
can-reset-overrides? (or (not components-v2) (seq touched-not-dangling))
;; For when it's only one shape
@ -337,16 +336,22 @@
lacks-annotation? (nil? (:annotation component))
is-dangling? (nil? component)
can-update-main? (or (not components-v2)
(and
can-show-component? (and (not multi)
(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
#(st/emit! (dwl/detach-components (map :id copies)))
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
#(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)
{:msg "workspace.shape.menu.restore-main"
:action do-restore-component})
(when (and (not multi) (not main-instance?) (not is-dangling?))
(when can-show-component?
{:msg "workspace.shape.menu.show-main"
:action do-show-component})
(when (and (not multi) can-update-main? (not is-dangling?))
(when can-update-main?
{:msg "workspace.shape.menu.update-main"
:action do-update-component})]]
(filter (complement nil?) menu-entries)))