🐛 Fix problems with mov-objects

This commit is contained in:
alonso.torres 2021-05-26 13:25:07 +02:00 committed by Andrey Antukh
parent ba211e3cbd
commit 52f699c175
2 changed files with 20 additions and 17 deletions

View File

@ -221,28 +221,31 @@
;; the new destination target parent id. ;; the new destination target parent id.
(if (= prev-parent-id parent-id) (if (= prev-parent-id parent-id)
objects objects
(loop [sid shape-id (let [sid shape-id
pid prev-parent-id pid prev-parent-id
objects objects] obj (get objects pid)
(let [obj (get objects pid)] component? (and (:shape-ref obj)
(cond-> objects (= (:type obj) :group)
true (not ignore-touched))]
(update-in [pid :shapes] strip-id sid)
(and (:shape-ref obj) (-> objects
(= (:type obj) :group) (d/update-in-when [pid :shapes] strip-id sid)
(not ignore-touched))
(-> (cond-> component?
(update-in [pid :touched] (d/update-when
cph/set-touched-group :shapes-group) pid
(d/dissoc-in [pid :remote-synced?])))))))) #(-> %
(update :touched cph/set-touched-group :shapes-group)
(dissoc :remote-synced?)))))))))
(update-parent-id [objects id] (update-parent-id [objects id]
(assoc-in objects [id :parent-id] parent-id)) (-> objects
(d/update-when id assoc :parent-id parent-id)))
;; Updates the frame-id references that might be outdated ;; Updates the frame-id references that might be outdated
(assign-frame-id [frame-id objects id] (assign-frame-id [frame-id objects id]
(let [objects (update objects id assoc :frame-id frame-id) (let [objects (-> objects
(d/update-when id assoc :frame-id frame-id))
obj (get objects id)] obj (get objects id)]
(cond-> objects (cond-> objects
;; If we moving frame, the parent frame is the root ;; If we moving frame, the parent frame is the root

View File

@ -181,7 +181,7 @@
(defn calculate-invalid-targets (defn calculate-invalid-targets
[shape-id objects] [shape-id objects]
(let [result #{shape-id} (let [result #{shape-id}
children (get-in objects [shape-id :shape]) children (get-in objects [shape-id :shapes])
reduce-fn (fn [result child-id] reduce-fn (fn [result child-id]
(into result (calculate-invalid-targets child-id objects)))] (into result (calculate-invalid-targets child-id objects)))]
(reduce reduce-fn result children))) (reduce reduce-fn result children)))