mirror of
https://github.com/penpot/penpot.git
synced 2025-01-26 08:29:42 -05:00
🐛 Properly handle nil values on update-shapes
function.
This commit is contained in:
parent
bae709df5b
commit
b2e7bb6be1
1 changed files with 19 additions and 18 deletions
|
@ -66,10 +66,10 @@
|
||||||
|
|
||||||
(cond-> changes
|
(cond-> changes
|
||||||
(not (empty? rops))
|
(not (empty? rops))
|
||||||
(update :rch conj (assoc change :operations rops))
|
(update :redo-changes conj (assoc change :operations rops))
|
||||||
|
|
||||||
(not (empty? uops))
|
(not (empty? uops))
|
||||||
(update :uch conj (assoc change :operations uops)))))
|
(update :undo-changes conj (assoc change :operations uops)))))
|
||||||
|
|
||||||
(defn update-shapes
|
(defn update-shapes
|
||||||
([ids f] (update-shapes ids f nil))
|
([ids f] (update-shapes ids f nil))
|
||||||
|
@ -82,25 +82,26 @@
|
||||||
(ptk/reify ::update-shapes
|
(ptk/reify ::update-shapes
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state stream]
|
(watch [it state stream]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (wsh/lookup-page-objects state)
|
objects (wsh/lookup-page-objects state)
|
||||||
reg-objects {:type :reg-objects :page-id page-id :shapes (vec ids)}
|
changes {:redo-changes []
|
||||||
|
:undo-changes []
|
||||||
|
:origin it
|
||||||
|
:save-undo? save-undo?}
|
||||||
|
|
||||||
{redo-changes :rch undo-changes :uch}
|
ids (into [] (filter some?) ids)
|
||||||
(reduce #(update-shape-changes %1 page-id objects f keys %2)
|
|
||||||
{:rch [] :uch []} ids)]
|
|
||||||
|
|
||||||
(when-not (empty? redo-changes)
|
changes (reduce #(update-shape-changes %1 page-id objects f keys %2) changes ids)]
|
||||||
(let [redo-changes (cond-> redo-changes
|
|
||||||
reg-objects? (conj reg-objects))
|
|
||||||
|
|
||||||
undo-changes (cond-> undo-changes
|
(when-not (empty? (:redo-changes changes))
|
||||||
reg-objects? (conj reg-objects))]
|
(let [reg-objs {:type :reg-objects
|
||||||
|
:page-id page-id
|
||||||
(rx/of (commit-changes {:redo-changes redo-changes
|
:shapes ids}
|
||||||
:undo-changes undo-changes
|
changes (cond-> changes
|
||||||
:origin it
|
reg-objects?
|
||||||
:save-undo? save-undo?})))))))))
|
(-> (update :redo-changes conj reg-objs)
|
||||||
|
(update :undo-changes conj reg-objs)))]
|
||||||
|
(rx/of (commit-changes changes)))))))))
|
||||||
|
|
||||||
(defn update-indices
|
(defn update-indices
|
||||||
[page-id changes]
|
[page-id changes]
|
||||||
|
|
Loading…
Add table
Reference in a new issue