mirror of
https://github.com/penpot/penpot.git
synced 2025-05-16 01:26:38 +02:00
⚡ Change some verify to asserts
This commit is contained in:
parent
ac27d35ff5
commit
0b6c2df5b6
3 changed files with 13 additions and 10 deletions
|
@ -31,7 +31,7 @@
|
||||||
;; When verify? false we spec the schema validation. Currently used to make just
|
;; When verify? false we spec the schema validation. Currently used to make just
|
||||||
;; 1 validation even if the changes are applied twice
|
;; 1 validation even if the changes are applied twice
|
||||||
(when verify?
|
(when verify?
|
||||||
(us/verify ::spec/changes items))
|
(us/assert ::spec/changes items))
|
||||||
|
|
||||||
(let [pages (into #{} (map :page-id) items)
|
(let [pages (into #{} (map :page-id) items)
|
||||||
result (->> items
|
result (->> items
|
||||||
|
|
|
@ -68,15 +68,18 @@
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (get-in state [:workspace-data :pages-index page-id :objects])]
|
objects (get-in state [:workspace-data :pages-index page-id :objects])
|
||||||
|
reg-objects {:type :reg-objects :page-id page-id :shapes (vec ids)}]
|
||||||
(loop [ids (seq ids)
|
(loop [ids (seq ids)
|
||||||
rch []
|
rch []
|
||||||
uch []]
|
uch []]
|
||||||
(if (nil? ids)
|
(if (nil? ids)
|
||||||
(rx/of (commit-changes
|
(rx/of (let [has-rch? (not (empty? rch))
|
||||||
(cond-> rch reg-objects? (conj {:type :reg-objects :page-id page-id :shapes (vec ids)}))
|
has-uch? (not (empty? uch))
|
||||||
(cond-> uch reg-objects? (conj {:type :reg-objects :page-id page-id :shapes (vec ids)}))
|
rch (cond-> rch (and has-rch? reg-objects?) (conj reg-objects))
|
||||||
{:commit-local? true}))
|
uch (cond-> uch (and has-rch? reg-objects?) (conj reg-objects))]
|
||||||
|
(when (and has-rch? has-uch?)
|
||||||
|
(commit-changes rch uch {:commit-local? true}))))
|
||||||
|
|
||||||
(let [id (first ids)
|
(let [id (first ids)
|
||||||
obj1 (get objects id)
|
obj1 (get objects id)
|
||||||
|
@ -161,8 +164,8 @@
|
||||||
:or {save-undo? true
|
:or {save-undo? true
|
||||||
commit-local? false}
|
commit-local? false}
|
||||||
:as opts}]
|
:as opts}]
|
||||||
(us/verify ::cp/changes changes)
|
(us/assert ::cp/changes changes)
|
||||||
(us/verify ::cp/changes undo-changes)
|
(us/assert ::cp/changes undo-changes)
|
||||||
(log/debug :msg "commit-changes"
|
(log/debug :msg "commit-changes"
|
||||||
:js/changes changes
|
:js/changes changes
|
||||||
:js/undo-changes undo-changes)
|
:js/undo-changes undo-changes)
|
||||||
|
@ -183,7 +186,7 @@
|
||||||
[:workspace-data]
|
[:workspace-data]
|
||||||
[:workspace-libraries file-id :data])]
|
[:workspace-libraries file-id :data])]
|
||||||
(try
|
(try
|
||||||
(us/verify ::spec/changes changes)
|
(us/assert ::spec/changes changes)
|
||||||
(let [state (update-in state path1 cp/process-changes changes false)]
|
(let [state (update-in state path1 cp/process-changes changes false)]
|
||||||
(cond-> state
|
(cond-> state
|
||||||
commit-local? (update-in path2 cp/process-changes changes false)))
|
commit-local? (update-in path2 cp/process-changes changes false)))
|
||||||
|
|
|
@ -83,7 +83,7 @@
|
||||||
|
|
||||||
(defn- append-undo
|
(defn- append-undo
|
||||||
[entry]
|
[entry]
|
||||||
(us/verify ::undo-entry entry)
|
(us/assert ::undo-entry entry)
|
||||||
(ptk/reify ::append-undo
|
(ptk/reify ::append-undo
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue