mirror of
https://github.com/penpot/penpot.git
synced 2025-05-11 11:46:37 +02: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
|
(defmethod process-change :add-page
|
||||||
[data {:keys [id name page]}]
|
[data {:keys [id name page]}]
|
||||||
(cond
|
(when (and id name page)
|
||||||
(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
|
|
||||||
(ex/raise :type :conflict
|
(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
|
(defmethod process-change :mod-page
|
||||||
[data {:keys [id name]}]
|
[data {:keys [id name]}]
|
||||||
|
|
|
@ -141,6 +141,11 @@
|
||||||
(try
|
(try
|
||||||
(us/assert ::spec/changes redo-changes)
|
(us/assert ::spec/changes redo-changes)
|
||||||
(us/assert ::spec/changes undo-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)
|
(update-in state path cp/process-changes redo-changes false)
|
||||||
|
|
||||||
(catch :default e
|
(catch :default e
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue