mirror of
https://github.com/penpot/penpot.git
synced 2026-09-07 04:29:31 +00:00
Fix wrong behavior of page packing and unpacking.
Bug introduced in previous state attribute naming refactor.
This commit is contained in:
parent
c8683ea0ba
commit
7acfcbe09c
@ -27,13 +27,13 @@
|
|||||||
|
|
||||||
(defn dissoc-page-shapes
|
(defn dissoc-page-shapes
|
||||||
[state id]
|
[state id]
|
||||||
(let [shapes (get-in state [:shapes])]
|
(let [shapes (get state :shapes)]
|
||||||
(assoc state :shapes (reduce-kv (fn [acc k v]
|
(assoc state :shapes (reduce-kv (fn [acc k v]
|
||||||
(if (= (:page v) id)
|
(if (= (:page v) id)
|
||||||
(dissoc acc k)
|
(dissoc acc k)
|
||||||
acc))
|
acc))
|
||||||
shapes
|
shapes
|
||||||
shapes))))
|
shapes))))
|
||||||
|
|
||||||
(defn pack-page
|
(defn pack-page
|
||||||
"Return a packed version of page object ready
|
"Return a packed version of page object ready
|
||||||
@ -44,22 +44,21 @@
|
|||||||
shapes (into {} xf (:shapes state))]
|
shapes (into {} xf (:shapes state))]
|
||||||
(-> page
|
(-> page
|
||||||
(assoc-in [:data :shapes] (into [] (:shapes page)))
|
(assoc-in [:data :shapes] (into [] (:shapes page)))
|
||||||
(assoc-in [:data :shapes] shapes)
|
(assoc-in [:data :shapes-map] shapes)
|
||||||
(update-in [:data] dissoc :items)
|
|
||||||
(dissoc :shapes))))
|
(dissoc :shapes))))
|
||||||
|
|
||||||
(defn unpack-page
|
(defn unpack-page
|
||||||
"Unpacks packed page object and assocs it to the
|
"Unpacks packed page object and assocs it to the
|
||||||
provided state."
|
provided state."
|
||||||
[state page]
|
[state {:keys [id data] :as page}]
|
||||||
(let [data (:data page)
|
(let [shapes (:shapes data)
|
||||||
shapes (:shapes data)
|
shapes-map (:shapes-map data)
|
||||||
shapes-by-id (:shapes data)
|
page (-> page
|
||||||
page (-> (dissoc page :data)
|
(dissoc :data)
|
||||||
(assoc :shapes shapes))]
|
(assoc :shapes shapes))]
|
||||||
(-> state
|
(-> state
|
||||||
(update :shapes merge shapes-by-id)
|
(update :shapes merge shapes-map)
|
||||||
(update :pages assoc (:id page) page))))
|
(update :pages assoc id page))))
|
||||||
|
|
||||||
(defn purge-page
|
(defn purge-page
|
||||||
"Remove page and all related stuff from the state."
|
"Remove page and all related stuff from the state."
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user