From 50321895e53a6fdbac3e04dbcbb217aca4fd2326 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 14 Sep 2020 16:52:22 +0200 Subject: [PATCH] :bug: Fix proportion locking. --- frontend/src/app/main/data/workspace.cljs | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 91c7032c3..485b24a2a 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -152,8 +152,6 @@ (file-initialized project-id file-id)))) )))) - - (defn- file-initialized [project-id file-id] (ptk/reify ::file-initialized @@ -995,8 +993,6 @@ ;; Event mainly used for handling user modification of the size of the ;; object from workspace sidebar options inputs. -;; TODO: maybe replace directly with dwc/update-shapes? - (defn update-dimensions [ids attr value] (us/verify (s/coll-of ::us/uuid) ids) @@ -1012,17 +1008,14 @@ (defn set-shape-proportion-lock [id lock] - (js/alert "TODO: broken") - #_(ptk/reify ::set-shape-proportion-lock - ptk/UpdateEvent - (update [_ state] - (let [page-id (:current-page-id state) - shape (get-in state [:workspace-data page-id :objects id])] - (if-not lock - (assoc-in state [:workspace-data page-id :objects id :proportion-lock] lock)) - (->> (geom/assign-proportions (assoc shape :proportion-lock lock)) - (assoc-in state [:workspace-data page-id :objects id])))))) - + (ptk/reify ::set-shape-proportion-lock + ptk/WatchEvent + (watch [_ state stream] + (rx/of (dwc/update-shapes [id] (fn [shape] + (if-not lock + (assoc shape :proportion-lock false) + (-> (assoc shape :proportion-lock true) + (geom/assign-proportions))))))))) ;; --- Update Shape Position (s/def ::x number?)