0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 15:39:50 -05:00

🐛 Fix bad switch paths on files migrated to v2

This commit is contained in:
Pablo Alba 2023-11-28 20:08:27 +01:00
parent 9acab2a28a
commit f261cf6e63

View file

@ -201,6 +201,7 @@
workspace-libraries (mf/deref refs/workspace-libraries)
objects (mf/deref refs/workspace-page-objects)
libraries (assoc workspace-libraries current-file-id (assoc workspace-file :data workspace-data))
single-comp (ctf/get-component libraries (:component-file shape) (:component-id shape))
every-same-file? (every? #(= (:component-file shape) (:component-file %)) shapes)
current-comp-id (when (every? #(= (:component-id shape) (:component-id %)) shapes)
(:component-id shape))
@ -208,10 +209,10 @@
file-id (if every-same-file?
(:component-file shape)
current-file-id)
paths (->> shapes
(map :name)
(map cfh/split-path)
(map butlast))
orig-components (map #(ctf/get-component libraries (:component-file %) (:component-id %)) shapes)
paths (->> orig-components
(map :path)
(map cfh/split-path))
find-common-path (fn common-path [path n]
(let [current (nth (first paths) n nil)]
@ -221,7 +222,7 @@
(common-path (conj path current) (inc n)))))
path (if single?
(cfh/butlast-path (:name shape))
(:path single-comp)
(cfh/join-path (if (not every-same-file?)
""
(find-common-path [] 0))))