mirror of
https://github.com/penpot/penpot.git
synced 2025-03-10 14:51:37 -05:00
🐛 Ensure data integrity on :del-obj change impl.
This commit is contained in:
parent
d2f23fd95e
commit
9454302a83
1 changed files with 8 additions and 5 deletions
|
@ -215,11 +215,14 @@
|
|||
|
||||
(defmethod process-change :del-obj
|
||||
[data {:keys [id] :as change}]
|
||||
(when-let [{:keys [frame-id] :as obj} (get-in data [:objects id])]
|
||||
(-> data
|
||||
(update :objects dissoc id)
|
||||
(update-in [:objects frame-id :shapes]
|
||||
(fn [s] (filterv #(not= % id) s))))))
|
||||
(when-let [{:keys [frame-id shapes] :as obj} (get-in data [:objects id])]
|
||||
(let [data (update data :objects dissoc id)]
|
||||
(cond-> data
|
||||
(contains? (:objects data) frame-id)
|
||||
(update-in [:objects frame-id :shapes] (fn [s] (filterv #(not= % id) s)))
|
||||
|
||||
(seq shapes) ; Recursive delete all dependend objects
|
||||
(as-> $ (reduce #(process-change %1 {:type :del-obj :id %2}) $ shapes))))))
|
||||
|
||||
(defmethod process-operation :set
|
||||
[shape op]
|
||||
|
|
Loading…
Add table
Reference in a new issue