mirror of
https://github.com/penpot/penpot.git
synced 2025-06-11 19:01:38 +02:00
✨ Simplify shape deletion code.
This commit is contained in:
parent
1d678acdd9
commit
63f43d917b
1 changed files with 1 additions and 21 deletions
|
@ -1344,17 +1344,6 @@
|
||||||
(reverse (map :id rchanges)))]
|
(reverse (map :id rchanges)))]
|
||||||
(rx/of (commit-changes rchanges uchanges {:commit-local? true}))))))
|
(rx/of (commit-changes rchanges uchanges {:commit-local? true}))))))
|
||||||
|
|
||||||
(defn- delete-frame
|
|
||||||
[id]
|
|
||||||
(ptk/reify ::delete-shapes
|
|
||||||
ptk/WatchEvent
|
|
||||||
(watch [_ state stream]
|
|
||||||
(let [page-id (::page-id state)
|
|
||||||
objects (get-in state [:workspace-data page-id :objects])
|
|
||||||
obj (get objects id)
|
|
||||||
ids (d/concat [] (:shapes obj) [(:id obj)])]
|
|
||||||
(rx/of (delete-shapes ids))))))
|
|
||||||
|
|
||||||
(def delete-selected
|
(def delete-selected
|
||||||
"Deselect all and remove all selected shapes."
|
"Deselect all and remove all selected shapes."
|
||||||
(ptk/reify ::delete-selected
|
(ptk/reify ::delete-selected
|
||||||
|
@ -1366,17 +1355,8 @@
|
||||||
|
|
||||||
shapes (map lookup selected)
|
shapes (map lookup selected)
|
||||||
shape? #(not= (:type %) :frame)]
|
shape? #(not= (:type %) :frame)]
|
||||||
(cond
|
(rx/of (delete-shapes selected))))))
|
||||||
(and (= (count shapes) 1)
|
|
||||||
(= (:type (first shapes)) :frame))
|
|
||||||
(rx/of (delete-frame (first selected)))
|
|
||||||
|
|
||||||
(and (pos? (count shapes))
|
|
||||||
(every? shape? shapes))
|
|
||||||
(rx/of (delete-shapes selected))
|
|
||||||
|
|
||||||
:else
|
|
||||||
(rx/empty))))))
|
|
||||||
|
|
||||||
;; --- Rename Shape
|
;; --- Rename Shape
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue