0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 17:00:36 -05:00

🐛 Improved object deletion

This commit is contained in:
alonso.torres 2021-07-26 14:10:19 +02:00 committed by Andrey Antukh
parent 8493e51070
commit 43198eb263
3 changed files with 67 additions and 53 deletions

View file

@ -400,12 +400,14 @@
(into (d/ordered-set) empty-parents-xform all-parents)
mk-del-obj-xf
(comp (filter (partial contains? objects))
(map (fn [id]
{:type :del-obj
:page-id page-id
:id id}))
:id id})))
mk-add-obj-xf
(comp (filter (partial contains? objects))
(map (fn [id]
(let [item (get objects id)]
{:type :add-obj
@ -414,18 +416,20 @@
:index (cp/position-on-parent id objects)
:frame-id (:frame-id item)
:parent-id (:parent-id item)
:obj item})))
:obj item}))))
mk-mod-touched-xf
(comp (filter (partial contains? objects))
(map (fn [id]
(let [parent (get objects id)]
{:type :mod-obj
:page-id page-id
:id (:id parent)
:operations [{:type :set-touched
:touched (:touched parent)}]})))
:touched (:touched parent)}]}))))
mk-mod-int-del-xf
(comp (filter some?)
(map (fn [obj]
{:type :mod-obj
:page-id page-id
@ -434,33 +438,36 @@
:attr :interactions
:val (vec (remove (fn [interaction]
(contains? ids (:destination interaction)))
(:interactions obj)))}]}))
(:interactions obj)))}]})))
mk-mod-int-add-xf
(comp (filter some?)
(map (fn [obj]
{:type :mod-obj
:page-id page-id
:id (:id obj)
:operations [{:type :set
:attr :interactions
:val (:interactions obj)}]}))
:val (:interactions obj)}]})))
mk-mod-unmask-xf
(comp (filter (partial contains? objects))
(map (fn [id]
{:type :mod-obj
:page-id page-id
:id id
:operations [{:type :set
:attr :masked-group?
:val false}]}))
:val false}]})))
mk-mod-mask-xf
(comp (filter (partial contains? objects))
(map (fn [id]
{:type :mod-obj
:page-id page-id
:id id
:operations [{:type :set
:attr :masked-group?
:val true}]}))
:val true}]})))
rchanges
(-> []

View file

@ -67,8 +67,10 @@
(rx/of
(dch/update-shapes [id] #(assoc % :content content))
(dwu/commit-undo-transaction)))))
(when (some? id)
(rx/of (dws/deselect-shape id)
(dwc/delete-shapes #{id})))))))
(dwc/delete-shapes #{id}))))))))
(defn initialize-editor-state
[{:keys [id content] :as shape} decorator]

View file

@ -6,8 +6,10 @@
(ns app.main.ui.workspace
(:require
[app.util.timers :as ts]
[app.main.data.messages :as dm]
[app.main.data.workspace :as dw]
[app.main.data.workspace.persistence :as dwp]
[app.main.refs :as refs]
[app.main.store :as st]
[app.main.ui.context :as ctx]
@ -122,7 +124,10 @@
(mf/deps project-id file-id)
(fn []
(st/emit! (dw/initialize-file project-id file-id))
(st/emitf (dw/finalize-file project-id file-id))))
(fn []
;; Schedule to 100ms so we can do the update before the file is finalized
(st/emit! ::dwp/force-persist)
(ts/schedule 100 (st/emitf (dw/finalize-file project-id file-id))))))
(mf/use-effect
(fn []