0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-09 08:20:45 -05:00

🐛 Fix import of zip files from v2 to v2

This commit is contained in:
alonso.torres 2024-01-11 17:46:50 +01:00 committed by Andrey Antukh
parent 9ea440b6f7
commit 28981e5d46
3 changed files with 18 additions and 4 deletions

View file

@ -508,6 +508,7 @@
grc/empty-rect)
name (:name data)
path (:path data)
component-id (:component-id data)
main-instance-id (:main-instance-id data)
main-instance-page (:main-instance-page data)
attrs (-> data
@ -547,11 +548,17 @@
(defn finish-component
[file]
(let [component-id (:current-component-id file)
component-data (ctkl/get-component (:data file) component-id)
component (lookup-shape file component-id)
children (->> component :shapes (mapv #(lookup-shape file %)))
file
(cond
;; Components-v2 component we skip this step
(and component-data (:main-instance-id component-data))
file
(empty? children)
(commit-change
file

View file

@ -508,7 +508,7 @@
(mf/deps objects)
(fn [] (frame-wrapper-factory objects)))]
[:> "symbol" #js {:id (str root-id)
[:> "symbol" #js {:id (str (:id component))
:viewBox vbox
"penpot:path" path
"penpot:main-instance-id" main-instance-id

View file

@ -137,7 +137,11 @@
:is-shared (:shared context)
:project-id (:project-id context)
:create-page false
:features features})))
;; If the features object exists send that. Otherwise we remove the components/v2 because
;; if the features attribute doesn't exist is a version < 2.0. The other features will
;; be kept so the shapes are created full featured
:features (d/nilv (:features context) (disj features "components/v2"))})))
(defn link-file-libraries
"Create a new file on the back-end"
@ -154,7 +158,8 @@
[context file]
(let [file-id (:id file)
session-id (uuid/next)
batches (->> (fb/generate-changes file)
changes (fb/generate-changes file)
batches (->> changes
(partition change-batch-size change-batch-size nil)
(mapv vec))
@ -538,7 +543,9 @@
(rx/merge-map (comp d/kebab-keys parser/string->uuid))
(rx/mapcat
(fn [[id media]]
(let [media (assoc media :id (resolve id))]
(let [media (-> media
(assoc :id (resolve id))
(update :name str))]
(->> (get-file context :media id media)
(rx/map (fn [blob]
(let [content (.slice blob 0 (.-size blob) (:mtype media))]