mirror of
https://github.com/penpot/penpot.git
synced 2025-03-13 00:01:51 -05:00
🐛 Fixes problem recreating indices
This commit is contained in:
parent
0cc600de6d
commit
7033ae4f2e
2 changed files with 29 additions and 29 deletions
|
@ -57,8 +57,9 @@
|
||||||
{:index index :z-index z-index}))
|
{:index index :z-index z-index}))
|
||||||
|
|
||||||
(defn- update-index
|
(defn- update-index
|
||||||
[{index :index z-index :z-index} old-objects new-objects]
|
[{index :index z-index :z-index :as data} old-objects new-objects]
|
||||||
|
|
||||||
|
(if (some? data)
|
||||||
(let [changes? (fn [id]
|
(let [changes? (fn [id]
|
||||||
(not= (get old-objects id)
|
(not= (get old-objects id)
|
||||||
(get new-objects id)))
|
(get new-objects id)))
|
||||||
|
@ -80,7 +81,10 @@
|
||||||
|
|
||||||
z-index (cp/update-z-index z-index changed-ids old-objects new-objects)]
|
z-index (cp/update-z-index z-index changed-ids old-objects new-objects)]
|
||||||
|
|
||||||
{:index index :z-index z-index}))
|
{:index index :z-index z-index})
|
||||||
|
|
||||||
|
;; If not previous data. We need to create from scratch
|
||||||
|
(create-index new-objects)))
|
||||||
|
|
||||||
(defn- query-index
|
(defn- query-index
|
||||||
[{index :index z-index :z-index} rect frame-id include-frames? include-groups? disabled-masks reverse?]
|
[{index :index z-index :z-index} rect frame-id include-frames? include-groups? disabled-masks reverse?]
|
||||||
|
|
|
@ -39,16 +39,15 @@
|
||||||
(rt/insert tree (coord point) data))]
|
(rt/insert tree (coord point) data))]
|
||||||
(->> shapes
|
(->> shapes
|
||||||
(mapcat (process-shape frame-id coord))
|
(mapcat (process-shape frame-id coord))
|
||||||
(reduce into-tree data))))
|
(reduce into-tree (or data (rt/make-tree))))))
|
||||||
|
|
||||||
(defn remove-coord-data
|
(defn remove-coord-data
|
||||||
[data frame-id shapes coord]
|
[data frame-id shapes coord]
|
||||||
|
|
||||||
(letfn [(remove-tree [tree [point _ :as data]]
|
(letfn [(remove-tree [tree [point _ :as data]]
|
||||||
(rt/remove tree (coord point) data))]
|
(rt/remove tree (coord point) data))]
|
||||||
(->> shapes
|
(->> shapes
|
||||||
(mapcat (process-shape frame-id coord))
|
(mapcat (process-shape frame-id coord))
|
||||||
(reduce remove-tree data))))
|
(reduce remove-tree (or data (rt/make-tree))))))
|
||||||
|
|
||||||
(defn aggregate-data
|
(defn aggregate-data
|
||||||
([objects]
|
([objects]
|
||||||
|
@ -117,16 +116,13 @@
|
||||||
add-frames
|
add-frames
|
||||||
(fn [snap-data frame-id]
|
(fn [snap-data frame-id]
|
||||||
(assoc snap-data frame-id {:x (rt/make-tree)
|
(assoc snap-data frame-id {:x (rt/make-tree)
|
||||||
:y (rt/make-tree)}))
|
:y (rt/make-tree)}))]
|
||||||
|
|
||||||
snap-data (as-> snap-data $
|
(as-> snap-data $
|
||||||
(reduce add-frames $ frames-to-add)
|
(reduce add-frames $ frames-to-add)
|
||||||
(reduce add-data $ to-add)
|
(reduce add-data $ to-add)
|
||||||
(reduce delete-data $ to-delete)
|
(reduce delete-data $ to-delete)
|
||||||
(reduce delete-frames $ frames-to-delete))
|
(reduce delete-frames $ frames-to-delete))))
|
||||||
]
|
|
||||||
|
|
||||||
snap-data))
|
|
||||||
|
|
||||||
(defn- log-state
|
(defn- log-state
|
||||||
"Helper function to print a friendly version of the snap tree. Debugging purposes"
|
"Helper function to print a friendly version of the snap tree. Debugging purposes"
|
||||||
|
|
Loading…
Add table
Reference in a new issue