🐛 Fix synchronization when adding a subcomponent to a instance

This commit is contained in:
Andrés Moya 2020-12-03 14:18:03 +01:00 committed by Andrey Antukh
parent b4246c2869
commit e9714c4fd0
4 changed files with 16 additions and 9 deletions

View file

@ -764,8 +764,8 @@
:frame-id frame-id
:parent-id parent-id
:id id)]
(if (and (contains? objects parent-id)
(contains? objects frame-id))
(if (and (or (nil? parent-id) (contains? objects parent-id))
(or (nil? frame-id) (contains? objects frame-id)))
(-> data
(update :objects assoc id obj)
(update-in [:objects parent-id :shapes]

View file

@ -10,8 +10,9 @@
(ns app.common.pages-helpers
(:require
[app.common.data :as d]
[app.common.uuid :as uuid]
[app.common.geom.shapes :as gsh]))
[app.common.geom.shapes :as gsh]
[app.common.spec :as us]
[app.common.uuid :as uuid]))
(defn walk-pages
"Go through all pages of a file and apply a function to each one"
@ -48,7 +49,7 @@
(defn page?
[container]
(assert (some? (:type container)))
(us/assert some? (:type container))
(= (:type container) :page))
(defn component?
@ -246,6 +247,7 @@
(let [child-id (first child-ids)
child (get objects child-id)
_ (us/assert some? child)
[new-child new-child-objects updated-child-objects]
(clone-object child new-id objects update-new-object update-original-object)]

View file

@ -664,8 +664,13 @@
root-instance)]
(cond-> new-shape
true
(assoc :shape-ref (:id original-shape)
:frame-id (:frame-id parent-shape))
(assoc :frame-id (:frame-id parent-shape))
(nil? (:shape-ref original-shape))
(assoc :shape-ref (:id original-shape))
(some? (:shape-ref original-shape))
(assoc :shape-ref (:shape-ref original-shape))
(:component-id original-shape)
(assoc :component-id (:component-id original-shape))
@ -685,7 +690,7 @@
[new-shape new-shapes _]
(cph/clone-object component-shape
(:id parent-shape)
(get container :objects)
(get component :objects)
update-new-shape
update-original-shape)

View file

@ -148,7 +148,7 @@
(when component-file (str/format "<%s> " (:name component-file)))
(:name component))))))))]
(println "[Workspace]")
(println "[Page]")
(show-shape (:id root) 0 objects)
(dorun (for [component (vals components)]