mirror of
https://github.com/penpot/penpot.git
synced 2025-01-22 22:49:01 -05:00
🐛 Fix undo on delete page does not preserve its order
This commit is contained in:
parent
469704def6
commit
be656bb4ef
3 changed files with 17 additions and 8 deletions
|
@ -22,6 +22,7 @@
|
|||
- Fix props preserving on copy&paste texts [Taiga #3629](https://tree.taiga.io/project/penpot/issue/3629) by @andrewzhurov
|
||||
- Fix unexpected layers ungrouping on moving it [Taiga #3932](https://tree.taiga.io/project/penpot/issue/3932) by @andrewzhurov
|
||||
- Fix artboards moving with comment tool selected [Taiga #3938](https://tree.taiga.io/project/penpot/issue/3938)
|
||||
- Fix undo on delete page does not preserve its order [Taiga #3375](https://tree.taiga.io/project/penpot/issue/3375)
|
||||
|
||||
### :arrow_up: Deps updates
|
||||
### :heart: Community contributions by (Thank you!)
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
(ns app.common.types.pages-list
|
||||
(:require
|
||||
[app.common.data :as d]))
|
||||
[app.common.data :as d]
|
||||
[app.common.pages.helpers :as cph]))
|
||||
|
||||
(defn get-page
|
||||
[file-data id]
|
||||
|
@ -14,14 +15,18 @@
|
|||
|
||||
(defn add-page
|
||||
[file-data page]
|
||||
(let [; It's legitimate to add a page that is already there,
|
||||
(let [index (:index page)
|
||||
page (dissoc page :index)
|
||||
|
||||
; It's legitimate to add a page that is already there,
|
||||
; for example in an idempotent changes operation.
|
||||
conj-if-not-exists (fn [pages id]
|
||||
(cond-> pages
|
||||
(not (d/seek #(= % id) pages))
|
||||
(conj id)))]
|
||||
add-if-not-exists (fn [pages id]
|
||||
(cond
|
||||
(d/seek #(= % id) pages) pages
|
||||
(nil? index) (conj pages id)
|
||||
:else (cph/insert-at-index pages index [id])))]
|
||||
(-> file-data
|
||||
(update :pages conj-if-not-exists (:id page))
|
||||
(update :pages add-if-not-exists (:id page))
|
||||
(update :pages-index assoc (:id page) page))))
|
||||
|
||||
(defn pages-seq
|
||||
|
|
|
@ -326,7 +326,10 @@
|
|||
(ptk/reify ::delete-page
|
||||
ptk/WatchEvent
|
||||
(watch [it state _]
|
||||
(let [page (get-in state [:workspace-data :pages-index id])
|
||||
(let [pages (get-in state [:workspace-data :pages])
|
||||
index (d/index-of pages id)
|
||||
page (get-in state [:workspace-data :pages-index id])
|
||||
page (assoc page :index index)
|
||||
|
||||
changes (-> (pcb/empty-changes it)
|
||||
(pcb/del-page page))]
|
||||
|
|
Loading…
Add table
Reference in a new issue