Remove state assignation round-trip on update-dimensions event

Using the lower-level apply-modifiers event, introduced in previous
commit
This commit is contained in:
Andrey Antukh 2025-03-18 11:00:00 +01:00
parent 86c2c4cd41
commit 8df12e5e9c

View file

@ -340,35 +340,35 @@
(rx/filter (ptk/type? ::trigger-bounding-box-cloaking) stream))))))) (rx/filter (ptk/type? ::trigger-bounding-box-cloaking) stream)))))))
(defn update-dimensions (defn update-dimensions
"Change size of shapes, from the sideber options form. "Change size of shapes, from the sidebar options form
Will ignore pixel snap used in the options side panel" (will ignore pixel snap)"
([ids attr value] (update-dimensions ids attr value nil)) ([ids attr value] (update-dimensions ids attr value nil))
([ids attr value options] ([ids attr value options]
(dm/assert! (number? value)) (assert (number? value))
(dm/assert! (assert (every? uuid? ids)
"expected valid coll of uuids" "expected valid coll of uuids")
(every? uuid? ids)) (assert (contains? #{:width :height} attr)
(dm/assert! "expected valid attr")
"expected valid attr"
(contains? #{:width :height} attr)) (ptk/reify ::update-dimensions
(ptk/reify ::update-dimensions ptk/WatchEvent
ptk/UpdateEvent (watch [_ state _]
(update [_ state] (let [page-id
(let [page-id (or (get options :page-id) (or (get options :page-id)
(get state :current-page-id)) (get state :current-page-id))
objects
(dsh/lookup-page-objects state page-id)
objects (dsh/lookup-page-objects state page-id)
get-modifier get-modifier
(fn [shape] (ctm/change-dimensions-modifiers shape attr value)) (fn [shape]
(ctm/change-dimensions-modifiers shape attr value))
modif-tree modif-tree
(-> (dwm/build-modif-tree ids objects get-modifier) (-> (dwm/build-modif-tree ids objects get-modifier)
(gm/set-objects-modifiers objects))] (gm/set-objects-modifiers objects))]
(assoc state :workspace-modifiers modif-tree))) (rx/of (dwm/apply-modifiers* objects modif-tree nil options)))))))
ptk/WatchEvent
(watch [_ _ _]
(rx/of (dwm/apply-modifiers options))))))
(defn change-orientation (defn change-orientation
"Change orientation of shapes, from the sidebar options form. "Change orientation of shapes, from the sidebar options form.