mirror of
https://github.com/penpot/penpot.git
synced 2025-04-16 08:51:32 -05:00
🐛 Fix when a component annotation is changed on a library, update dialog appears
This commit is contained in:
parent
463d81745b
commit
b98f693959
2 changed files with 44 additions and 19 deletions
|
@ -177,3 +177,23 @@
|
|||
:remote-synced
|
||||
:shape-ref
|
||||
:touched))
|
||||
|
||||
|
||||
(defn- extract-ids [shape]
|
||||
(if (map? shape)
|
||||
(let [current-id (:id shape)
|
||||
child-ids (mapcat extract-ids (:children shape))]
|
||||
(cons current-id child-ids))
|
||||
[]))
|
||||
|
||||
(defn diff-components
|
||||
"Compare two components, and return a set of the keys with different values"
|
||||
[comp1 comp2]
|
||||
(let [eq (fn [key val1 val2]
|
||||
(if (= key :objects)
|
||||
(= (extract-ids val1) (extract-ids val2))
|
||||
(= val1 val2)))]
|
||||
(->> (concat (keys comp1) (keys comp2))
|
||||
(distinct)
|
||||
(filter #(not (eq % (get comp1 %) (get comp2 %))))
|
||||
set)))
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
[app.common.data.macros :as dm]
|
||||
[app.common.features :as cfeat]
|
||||
[app.common.time :as dt]
|
||||
[app.common.types.component :as ctk]))
|
||||
[app.common.types.component :as ctk]
|
||||
[clojure.set :as set]))
|
||||
|
||||
(defn components
|
||||
([file-data] (components file-data nil))
|
||||
|
@ -51,31 +52,35 @@
|
|||
(let [wrap-objects-fn cfeat/*wrap-with-objects-map-fn*]
|
||||
(d/update-in-when file-data [:components id]
|
||||
(fn [component]
|
||||
(let [objects (some-> objects wrap-objects-fn)]
|
||||
(cond-> component
|
||||
(some? name)
|
||||
(assoc :name name)
|
||||
(let [objects (some-> objects wrap-objects-fn)
|
||||
new-comp (cond-> component
|
||||
(some? name)
|
||||
(assoc :name name)
|
||||
|
||||
(some? path)
|
||||
(assoc :path path)
|
||||
(some? path)
|
||||
(assoc :path path)
|
||||
|
||||
(some? main-instance-id)
|
||||
(assoc :main-instance-id main-instance-id)
|
||||
(some? main-instance-id)
|
||||
(assoc :main-instance-id main-instance-id)
|
||||
|
||||
(some? main-instance-page)
|
||||
(assoc :main-instance-page main-instance-page)
|
||||
(some? main-instance-page)
|
||||
(assoc :main-instance-page main-instance-page)
|
||||
|
||||
(some? objects)
|
||||
(assoc :objects objects)
|
||||
(some? objects)
|
||||
(assoc :objects objects)
|
||||
|
||||
(some? annotation)
|
||||
(assoc :annotation annotation)
|
||||
(some? annotation)
|
||||
(assoc :annotation annotation)
|
||||
|
||||
(nil? annotation)
|
||||
(dissoc :annotation)
|
||||
(nil? annotation)
|
||||
(dissoc :annotation))
|
||||
diff (set/difference
|
||||
(ctk/diff-components component new-comp)
|
||||
#{:annotation})] ;; The set of properties that doesn't mark a component as touched
|
||||
|
||||
:always
|
||||
(touch)))))))
|
||||
(if (empty? diff)
|
||||
new-comp
|
||||
(touch new-comp)))))))
|
||||
|
||||
(defn get-component
|
||||
([file-data component-id]
|
||||
|
|
Loading…
Add table
Reference in a new issue