mirror of
https://github.com/penpot/penpot.git
synced 2025-03-12 07:41:43 -05:00
✨ Prevent leave stream broken on spec failed on commit-changes.
This commit is contained in:
parent
8ae6176242
commit
3db9907c25
1 changed files with 25 additions and 18 deletions
|
@ -67,18 +67,25 @@
|
||||||
:as opts}]
|
:as opts}]
|
||||||
(us/verify ::cp/changes changes)
|
(us/verify ::cp/changes changes)
|
||||||
;; (us/verify ::cp/changes undo-changes)
|
;; (us/verify ::cp/changes undo-changes)
|
||||||
|
|
||||||
|
(let [error (volatile! nil)]
|
||||||
(ptk/reify ::commit-changes
|
(ptk/reify ::commit-changes
|
||||||
cljs.core/IDeref
|
cljs.core/IDeref
|
||||||
(-deref [_] changes)
|
(-deref [_] changes)
|
||||||
|
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
|
(try
|
||||||
(let [state (update-in state [:workspace-file :data] cp/process-changes changes)]
|
(let [state (update-in state [:workspace-file :data] cp/process-changes changes)]
|
||||||
(cond-> state
|
(cond-> state
|
||||||
commit-local? (update :workspace-data cp/process-changes changes))))
|
commit-local? (update :workspace-data cp/process-changes changes)))
|
||||||
|
(catch :default e
|
||||||
|
(vreset! error e)
|
||||||
|
state)))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
|
(when-not @error
|
||||||
(let [page-id (:current-page-id state)]
|
(let [page-id (:current-page-id state)]
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(when (some :page-id changes)
|
(when (some :page-id changes)
|
||||||
|
@ -87,7 +94,7 @@
|
||||||
(when (and save-undo? (seq undo-changes))
|
(when (and save-undo? (seq undo-changes))
|
||||||
(let [entry {:undo-changes undo-changes
|
(let [entry {:undo-changes undo-changes
|
||||||
:redo-changes changes}]
|
:redo-changes changes}]
|
||||||
(rx/of (append-undo entry))))))))))
|
(rx/of (append-undo entry))))))))))))
|
||||||
|
|
||||||
(defn generate-operations
|
(defn generate-operations
|
||||||
([ma mb] (generate-operations ma mb false))
|
([ma mb] (generate-operations ma mb false))
|
||||||
|
|
Loading…
Add table
Reference in a new issue