mirror of
https://github.com/penpot/penpot.git
synced 2025-01-10 00:40:30 -05:00
🐛 Fix problem when page deletion and undo.
Related to duplicated page reference in undo page deletion.
This commit is contained in:
parent
7efc1a0366
commit
17ae6bf89d
2 changed files with 22 additions and 16 deletions
|
@ -293,23 +293,24 @@
|
|||
|
||||
(defmethod process-change :add-page
|
||||
[data {:keys [id name page]}]
|
||||
(cond
|
||||
(and (string? name) (uuid? id))
|
||||
(let [page (assoc init/empty-page-data
|
||||
:id id
|
||||
:name name)]
|
||||
(-> data
|
||||
(update :pages conj id)
|
||||
(update :pages-index assoc id page)))
|
||||
|
||||
(map? page)
|
||||
(-> data
|
||||
(update :pages conj (:id page))
|
||||
(update :pages-index assoc (:id page) page))
|
||||
|
||||
:else
|
||||
(when (and id name page)
|
||||
(ex/raise :type :conflict
|
||||
:hint "name or page should be provided, never both")))
|
||||
:hint "name or page should be provided, never both"))
|
||||
(letfn [(conj-if-not-exists [pages id]
|
||||
(cond-> pages
|
||||
(not (d/seek #(= % id) pages))
|
||||
(conj id)))]
|
||||
(if (and (string? name) (uuid? id))
|
||||
(let [page (assoc init/empty-page-data
|
||||
:id id
|
||||
:name name)]
|
||||
(-> data
|
||||
(update :pages conj-if-not-exists id)
|
||||
(update :pages-index assoc id page)))
|
||||
|
||||
(-> data
|
||||
(update :pages conj-if-not-exists (:id page))
|
||||
(update :pages-index assoc (:id page) page)))))
|
||||
|
||||
(defmethod process-change :mod-page
|
||||
[data {:keys [id name]}]
|
||||
|
|
|
@ -141,6 +141,11 @@
|
|||
(try
|
||||
(us/assert ::spec/changes redo-changes)
|
||||
(us/assert ::spec/changes undo-changes)
|
||||
|
||||
;; (prn "====== commit-changes ======" path)
|
||||
;; (cljs.pprint/pprint redo-changes)
|
||||
;; (cljs.pprint/pprint undo-changes)
|
||||
|
||||
(update-in state path cp/process-changes redo-changes false)
|
||||
|
||||
(catch :default e
|
||||
|
|
Loading…
Reference in a new issue