mirror of
https://github.com/penpot/penpot.git
synced 2025-03-12 15:51:37 -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}))
|
||||
|
||||
(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]
|
||||
(not= (get old-objects id)
|
||||
(get new-objects id)))
|
||||
|
@ -80,7 +81,10 @@
|
|||
|
||||
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
|
||||
[{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))]
|
||||
(->> shapes
|
||||
(mapcat (process-shape frame-id coord))
|
||||
(reduce into-tree data))))
|
||||
(reduce into-tree (or data (rt/make-tree))))))
|
||||
|
||||
(defn remove-coord-data
|
||||
[data frame-id shapes coord]
|
||||
|
||||
(letfn [(remove-tree [tree [point _ :as data]]
|
||||
(rt/remove tree (coord point) data))]
|
||||
(->> shapes
|
||||
(mapcat (process-shape frame-id coord))
|
||||
(reduce remove-tree data))))
|
||||
(reduce remove-tree (or data (rt/make-tree))))))
|
||||
|
||||
(defn aggregate-data
|
||||
([objects]
|
||||
|
@ -117,16 +116,13 @@
|
|||
add-frames
|
||||
(fn [snap-data frame-id]
|
||||
(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-data $ to-add)
|
||||
(reduce delete-data $ to-delete)
|
||||
(reduce delete-frames $ frames-to-delete))
|
||||
]
|
||||
|
||||
snap-data))
|
||||
(reduce delete-frames $ frames-to-delete))))
|
||||
|
||||
(defn- log-state
|
||||
"Helper function to print a friendly version of the snap tree. Debugging purposes"
|
||||
|
|
Loading…
Add table
Reference in a new issue