mirror of
https://github.com/penpot/penpot.git
synced 2026-09-13 15:38:38 +00:00
🐛 Bulk remove tokens with a single undo action (#8208)
This commit is contained in:
parent
b8fdbd1ef8
commit
3e4f70f37b
@ -433,11 +433,18 @@
|
|||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state _]
|
(watch [it state _]
|
||||||
(let [data (dsh/lookup-file-data state)
|
(let [data (dsh/lookup-file-data state)
|
||||||
|
token-set (if set-id
|
||||||
|
(lookup-token-set state set-id)
|
||||||
|
(lookup-token-set state))
|
||||||
|
token (-> (get-tokens-lib state)
|
||||||
|
(ctob/get-token (ctob/get-id token-set) token-id))
|
||||||
|
token-type (:type token)
|
||||||
|
|
||||||
changes (-> (pcb/empty-changes it)
|
changes (-> (pcb/empty-changes it)
|
||||||
(pcb/with-library-data data)
|
(pcb/with-library-data data)
|
||||||
(pcb/set-token set-id token-id nil))]
|
(pcb/set-token set-id token-id nil))]
|
||||||
(rx/of (dch/commit-changes changes))))))
|
(rx/of (dch/commit-changes changes)
|
||||||
|
(ptk/data-event ::ev/event {::ev/name "delete-token" :type token-type}))))))
|
||||||
|
|
||||||
(defn bulk-delete-tokens
|
(defn bulk-delete-tokens
|
||||||
[set-id token-ids]
|
[set-id token-ids]
|
||||||
@ -445,9 +452,15 @@
|
|||||||
(dm/assert! (every? uuid? token-ids))
|
(dm/assert! (every? uuid? token-ids))
|
||||||
(ptk/reify ::bulk-delete-tokens
|
(ptk/reify ::bulk-delete-tokens
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ _ _]
|
(watch [it state _]
|
||||||
(apply rx/of
|
(let [data (dsh/lookup-file-data state)
|
||||||
(map #(delete-token set-id %) token-ids)))))
|
changes (reduce (fn [changes token-id]
|
||||||
|
(pcb/set-token changes set-id token-id nil))
|
||||||
|
(-> (pcb/empty-changes it)
|
||||||
|
(pcb/with-library-data data))
|
||||||
|
token-ids)]
|
||||||
|
(rx/of (dch/commit-changes changes)
|
||||||
|
(ptk/data-event ::ev/event {::ev/name "delete-token-node"}))))))
|
||||||
|
|
||||||
(defn duplicate-token
|
(defn duplicate-token
|
||||||
[token-id]
|
[token-id]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user