mirror of
https://github.com/penpot/penpot.git
synced 2025-02-03 04:49:03 -05:00
Convert some events from reify to deftype.
This commit is contained in:
parent
3a75a07de5
commit
db36c617bf
1 changed files with 22 additions and 12 deletions
|
@ -109,15 +109,21 @@
|
||||||
[data]
|
[data]
|
||||||
(AddShape. data))
|
(AddShape. data))
|
||||||
|
|
||||||
|
;; --- Delete Shape
|
||||||
|
|
||||||
|
(deftype DeleteShape [id]
|
||||||
|
udp/IPageUpdate
|
||||||
|
ptk/UpdateEvent
|
||||||
|
(update [_ state]
|
||||||
|
(println "DeleteShape$update" id)
|
||||||
|
(let [shape (get-in state [:shapes id])]
|
||||||
|
(impl/dissoc-shape state shape))))
|
||||||
|
|
||||||
(defn delete-shape
|
(defn delete-shape
|
||||||
"Remove the shape using its id."
|
"Remove the shape using its id."
|
||||||
[id]
|
[id]
|
||||||
(reify
|
{:pre [(uuid? id)]}
|
||||||
udp/IPageUpdate
|
(DeleteShape. id))
|
||||||
ptk/UpdateEvent
|
|
||||||
(update [_ state]
|
|
||||||
(let [shape (get-in state [:shapes id])]
|
|
||||||
(impl/dissoc-shape state shape)))))
|
|
||||||
|
|
||||||
(defn update-shape
|
(defn update-shape
|
||||||
"Just updates in place the shape."
|
"Just updates in place the shape."
|
||||||
|
@ -603,15 +609,19 @@
|
||||||
[]
|
[]
|
||||||
(DuplicateSelected.))
|
(DuplicateSelected.))
|
||||||
|
|
||||||
|
;; --- Delete Selected
|
||||||
|
|
||||||
|
(deftype DeleteSelected []
|
||||||
|
ptk/WatchEvent
|
||||||
|
(watch [_ state stream]
|
||||||
|
(let [selected (get-in state [:workspace :selected])]
|
||||||
|
(rx/from-coll
|
||||||
|
(into [(deselect-all)] (map #(delete-shape %) selected))))))
|
||||||
|
|
||||||
(defn delete-selected
|
(defn delete-selected
|
||||||
"Deselect all and remove all selected shapes."
|
"Deselect all and remove all selected shapes."
|
||||||
[]
|
[]
|
||||||
(reify
|
(DeleteSelected.))
|
||||||
ptk/WatchEvent
|
|
||||||
(watch [_ state s]
|
|
||||||
(let [selected (get-in state [:workspace :selected])]
|
|
||||||
(rx/from-coll
|
|
||||||
(into [(deselect-all)] (map #(delete-shape %) selected)))))))
|
|
||||||
|
|
||||||
(deftype UpdateSelectedShapesAttrs [attrs]
|
(deftype UpdateSelectedShapesAttrs [attrs]
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
|
|
Loading…
Add table
Reference in a new issue