mirror of
https://github.com/penpot/penpot.git
synced 2025-03-16 01:31:22 -05:00
🐛 Fix restore main component on a copy of a component from a library
This commit is contained in:
parent
752b26e063
commit
cfdf7766e3
2 changed files with 30 additions and 27 deletions
|
@ -291,31 +291,30 @@
|
|||
(ptk/reify ::fetch-bundle
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
(let [component-id (get-in state [:route :query-params :component-id])]
|
||||
(->> (rx/merge
|
||||
(rx/of (fetch-bundle-stage-1 project-id file-id))
|
||||
(->> (rx/merge
|
||||
(rx/of (fetch-bundle-stage-1 project-id file-id))
|
||||
|
||||
(->> stream
|
||||
(rx/filter (ptk/type? ::bundle-stage-1))
|
||||
(rx/observe-on :async)
|
||||
(rx/map deref)
|
||||
(rx/map fetch-bundle-stage-2))
|
||||
|
||||
(->> stream
|
||||
(rx/filter (ptk/type? ::bundle-stage-2))
|
||||
(rx/observe-on :async)
|
||||
(rx/map deref)
|
||||
(rx/map bundle-fetched))
|
||||
|
||||
(when-let [component-id (get-in state [:route :query-params :component-id])]
|
||||
(->> stream
|
||||
(rx/filter (ptk/type? ::bundle-stage-1))
|
||||
(rx/filter (ptk/type? ::workspace-initialized))
|
||||
(rx/observe-on :async)
|
||||
(rx/map deref)
|
||||
(rx/map fetch-bundle-stage-2))
|
||||
(rx/take 1)
|
||||
(rx/map #(go-to-component (uuid/uuid component-id))))))
|
||||
|
||||
(->> stream
|
||||
(rx/filter (ptk/type? ::bundle-stage-2))
|
||||
(rx/observe-on :async)
|
||||
(rx/map deref)
|
||||
(rx/map bundle-fetched))
|
||||
|
||||
(when component-id
|
||||
(->> stream
|
||||
(rx/filter (ptk/type? ::workspace-initialized))
|
||||
(rx/observe-on :async)
|
||||
(rx/take 1)
|
||||
(rx/map #(go-to-component (uuid/uuid component-id))))))
|
||||
|
||||
(rx/take-until
|
||||
(rx/filter (ptk/type? ::fetch-bundle) stream)))))))
|
||||
(rx/take-until
|
||||
(rx/filter (ptk/type? ::fetch-bundle) stream))))))
|
||||
|
||||
(defn initialize-file
|
||||
[project-id file-id]
|
||||
|
|
|
@ -307,7 +307,9 @@
|
|||
workspace-libraries (deref refs/workspace-libraries)
|
||||
current-file {:id current-file-id :data workspace-data}
|
||||
|
||||
find-component #(ctf/resolve-component % current-file workspace-libraries)
|
||||
find-component (fn [shape include-deleted?]
|
||||
(ctf/resolve-component
|
||||
shape current-file workspace-libraries {:include-deleted? include-deleted?}))
|
||||
|
||||
local-or-exists (fn [shape]
|
||||
(let [library-id (:component-file shape)]
|
||||
|
@ -315,11 +317,11 @@
|
|||
(some? (get workspace-libraries library-id)))))
|
||||
|
||||
restorable-copies (->> copies
|
||||
(filter #(nil? (find-component %)))
|
||||
(filter #(nil? (find-component % false)))
|
||||
(filter #(local-or-exists %)))
|
||||
|
||||
touched-not-dangling (filter #(and (cfh/component-touched? objects (:id %))
|
||||
(find-component %)) copies)
|
||||
(find-component % false)) copies)
|
||||
can-reset-overrides? (or (not components-v2) (seq touched-not-dangling))
|
||||
|
||||
|
||||
|
@ -332,7 +334,7 @@
|
|||
library-id (:component-file shape)
|
||||
|
||||
local-component? (= library-id current-file-id)
|
||||
component (find-component shape)
|
||||
component (find-component shape false)
|
||||
lacks-annotation? (nil? (:annotation component))
|
||||
is-dangling? (nil? component)
|
||||
|
||||
|
@ -385,7 +387,9 @@
|
|||
#(st/emit! (dw/go-to-component component-id))
|
||||
|
||||
do-show-remote-component
|
||||
#(st/emit! (dwl/nav-to-component-file library-id component))
|
||||
#(let [comp (find-component shape true)] ;; When the show-remote is after a restore, the component may still be deleted
|
||||
(when comp
|
||||
(st/emit! (dwl/nav-to-component-file library-id comp))))
|
||||
|
||||
do-show-component
|
||||
#(if local-component?
|
||||
|
@ -401,7 +405,7 @@
|
|||
|
||||
(st/emit! (dwl/restore-components comps-to-restore))
|
||||
(when (= 1 (count comps-to-restore))
|
||||
do-show-component))
|
||||
(ts/schedule 1000 do-show-component)))
|
||||
|
||||
menu-entries [(when (and (not multi) main-instance?)
|
||||
{:msg "workspace.shape.menu.show-in-assets"
|
||||
|
|
Loading…
Add table
Reference in a new issue