mirror of
https://github.com/penpot/penpot.git
synced 2025-02-08 08:09:14 -05:00
🐛 Fix change structure of comp doesn't update copies on another file
This commit is contained in:
parent
d6b60ce43a
commit
a5b156e0d6
3 changed files with 39 additions and 9 deletions
|
@ -732,7 +732,8 @@
|
|||
:main-instance-id (:main-instance-id new-component)
|
||||
:main-instance-page (:main-instance-page new-component)
|
||||
:annotation (:annotation new-component)
|
||||
:objects (:objects new-component)}) ;; this won't exist in components-v2 (except for deleted components)
|
||||
:objects (:objects new-component) ;; this won't exist in components-v2 (except for deleted components)
|
||||
:modified-at (:modified-at new-component)})
|
||||
(update :undo-changes conj {:type :mod-component
|
||||
:id id
|
||||
:name (:name prev-component)
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
(wrap-object-fn)))))))
|
||||
|
||||
(defn mod-component
|
||||
[file-data {:keys [id name path main-instance-id main-instance-page objects annotation]}]
|
||||
[file-data {:keys [id name path main-instance-id main-instance-page objects annotation modified-at]}]
|
||||
(let [wrap-objects-fn cfeat/*wrap-with-objects-map-fn*]
|
||||
(d/update-in-when file-data [:components id]
|
||||
(fn [component]
|
||||
|
@ -69,6 +69,9 @@
|
|||
(some? objects)
|
||||
(assoc :objects objects)
|
||||
|
||||
(some? modified-at)
|
||||
(assoc :modified-at modified-at)
|
||||
|
||||
(some? annotation)
|
||||
(assoc :annotation annotation)
|
||||
|
||||
|
@ -76,7 +79,7 @@
|
|||
(dissoc :annotation))
|
||||
diff (set/difference
|
||||
(ctk/diff-components component new-comp)
|
||||
#{:annotation})] ;; The set of properties that doesn't mark a component as touched
|
||||
#{:annotation :modified-at})] ;; The set of properties that doesn't mark a component as touched
|
||||
|
||||
(if (empty? diff)
|
||||
new-comp
|
||||
|
|
|
@ -1186,6 +1186,26 @@
|
|||
:callback do-update}]
|
||||
:tag :sync-dialog)))))))
|
||||
|
||||
|
||||
(defn touch-component
|
||||
"Update the modified-at attribute of the component to now"
|
||||
[id]
|
||||
(dm/verify! (uuid? id))
|
||||
(ptk/reify ::touch-component
|
||||
cljs.core/IDeref
|
||||
(-deref [_] [id])
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [it state _]
|
||||
(let [data (get state :workspace-data)
|
||||
changes (-> (pcb/empty-changes it)
|
||||
(pcb/with-library-data data)
|
||||
(pcb/update-component id #(assoc % :modified-at (dt/now))))]
|
||||
(rx/of (dch/commit-changes {:origin it
|
||||
:redo-changes (:redo-changes changes)
|
||||
:undo-changes []
|
||||
:save-undo? false}))))))
|
||||
|
||||
(defn component-changed
|
||||
"Notify that the component with the given id has changed, so it needs to be updated
|
||||
in the current file and in the copies. And also update its thumbnails."
|
||||
|
@ -1197,6 +1217,7 @@
|
|||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(rx/of
|
||||
(touch-component component-id)
|
||||
(launch-component-sync component-id file-id undo-group)))))
|
||||
|
||||
(defn watch-component-changes
|
||||
|
@ -1244,13 +1265,18 @@
|
|||
(map (partial ch/components-changed old-data))
|
||||
(reduce into #{})))]
|
||||
|
||||
(if (and (d/not-empty? changed-components) save-undo?)
|
||||
(do (log/info :msg "DETECTED COMPONENTS CHANGED"
|
||||
:ids (map str changed-components)
|
||||
:undo-group undo-group)
|
||||
(if (d/not-empty? changed-components)
|
||||
(if save-undo?
|
||||
(do (log/info :msg "DETECTED COMPONENTS CHANGED"
|
||||
:ids (map str changed-components)
|
||||
:undo-group undo-group)
|
||||
|
||||
(->> (rx/from changed-components)
|
||||
(rx/map #(component-changed % (:id old-data) undo-group))))
|
||||
(->> (rx/from changed-components)
|
||||
(rx/map #(component-changed % (:id old-data) undo-group))))
|
||||
;; even if save-undo? is false, we need to update the :modified-date of the component
|
||||
;; (for example, for undos)
|
||||
(->> (rx/from changed-components)
|
||||
(rx/map #(touch-component %))))
|
||||
(rx/empty)))))
|
||||
|
||||
changes-s
|
||||
|
|
Loading…
Add table
Reference in a new issue