0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-14 07:51:35 -05:00

Merge pull request #447 from penpot/improve-component-sync

 Improve some cases of nested components sync
This commit is contained in:
Andrey Antukh 2021-01-08 15:35:23 +01:00 committed by GitHub
commit 77c1163591
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -193,7 +193,7 @@
(log/debug :msg "Sync page in local file" :page-id (:id container))
(log/debug :msg "Sync component in local library" :component-id (:id container)))
(let [has-asset-reference? (has-asset-reference-fn asset-type library-id)
(let [has-asset-reference? (has-asset-reference-fn asset-type library-id (cp/page? container))
linked-shapes (cp/select-objects has-asset-reference? container)]
(loop [shapes (seq linked-shapes)
rchanges []
@ -213,10 +213,11 @@
(defn- has-asset-reference-fn
"Gets a function that checks if a shape uses some asset of the given type
in the given library."
[asset-type library-id]
[asset-type library-id page?]
(case asset-type
:components
(fn [shape] (and (:component-id shape)
(or (:component-root? shape) (not page?))
(= (:component-file shape) library-id)))
:colors
@ -443,9 +444,9 @@
both (fn [shape-inst shape-master]
(let [options (if-not (:component-id shape-inst)
options
{:omit-touched? false
{:omit-touched? true
:reset-touched? false
:copy-touched? true})]
:copy-touched? false})]
(generate-sync-shape-direct-recursive container
shape-inst