0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-03 21:09:00 -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) workspace-libraries (mf/deref refs/workspace-libraries)
objects (mf/deref refs/workspace-page-objects) objects (mf/deref refs/workspace-page-objects)
libraries (assoc workspace-libraries current-file-id (assoc workspace-file :data workspace-data)) 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) every-same-file? (every? #(= (:component-file shape) (:component-file %)) shapes)
current-comp-id (when (every? #(= (:component-id shape) (:component-id %)) shapes) current-comp-id (when (every? #(= (:component-id shape) (:component-id %)) shapes)
(:component-id shape)) (:component-id shape))
@ -208,10 +209,10 @@
file-id (if every-same-file? file-id (if every-same-file?
(:component-file shape) (:component-file shape)
current-file-id) current-file-id)
paths (->> shapes orig-components (map #(ctf/get-component libraries (:component-file %) (:component-id %)) shapes)
(map :name) paths (->> orig-components
(map cfh/split-path) (map :path)
(map butlast)) (map cfh/split-path))
find-common-path (fn common-path [path n] find-common-path (fn common-path [path n]
(let [current (nth (first paths) n nil)] (let [current (nth (first paths) n nil)]
@ -221,7 +222,7 @@
(common-path (conj path current) (inc n))))) (common-path (conj path current) (inc n)))))
path (if single? path (if single?
(cfh/butlast-path (:name shape)) (:path single-comp)
(cfh/join-path (if (not every-same-file?) (cfh/join-path (if (not every-same-file?)
"" ""
(find-common-path [] 0)))) (find-common-path [] 0))))