From 52f699c175fe10b75ce5cfecd212ed382430bbfe Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Wed, 26 May 2021 13:25:07 +0200 Subject: [PATCH] :bug: Fix problems with mov-objects --- common/app/common/pages/changes.cljc | 35 +++++++++++++++------------- common/app/common/pages/helpers.cljc | 2 +- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/common/app/common/pages/changes.cljc b/common/app/common/pages/changes.cljc index 4fa3f8b75..5d2624574 100644 --- a/common/app/common/pages/changes.cljc +++ b/common/app/common/pages/changes.cljc @@ -221,28 +221,31 @@ ;; the new destination target parent id. (if (= prev-parent-id parent-id) objects - (loop [sid shape-id - pid prev-parent-id - objects objects] - (let [obj (get objects pid)] - (cond-> objects - true - (update-in [pid :shapes] strip-id sid) + (let [sid shape-id + pid prev-parent-id + obj (get objects pid) + component? (and (:shape-ref obj) + (= (:type obj) :group) + (not ignore-touched))] - (and (:shape-ref obj) - (= (:type obj) :group) - (not ignore-touched)) - (-> - (update-in [pid :touched] - cph/set-touched-group :shapes-group) - (d/dissoc-in [pid :remote-synced?])))))))) + (-> objects + (d/update-in-when [pid :shapes] strip-id sid) + + (cond-> component? + (d/update-when + pid + #(-> % + (update :touched cph/set-touched-group :shapes-group) + (dissoc :remote-synced?))))))))) (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 (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)] (cond-> objects ;; If we moving frame, the parent frame is the root diff --git a/common/app/common/pages/helpers.cljc b/common/app/common/pages/helpers.cljc index 87299b2a3..9eb194c27 100644 --- a/common/app/common/pages/helpers.cljc +++ b/common/app/common/pages/helpers.cljc @@ -181,7 +181,7 @@ (defn calculate-invalid-targets [shape-id objects] (let [result #{shape-id} - children (get-in objects [shape-id :shape]) + children (get-in objects [shape-id :shapes]) reduce-fn (fn [result child-id] (into result (calculate-invalid-targets child-id objects)))] (reduce reduce-fn result children)))