mirror of
https://github.com/penpot/penpot.git
synced 2025-03-12 07:41:43 -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,30 +57,34 @@
|
|||
{: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]
|
||||
|
||||
(let [changes? (fn [id]
|
||||
(not= (get old-objects id)
|
||||
(get new-objects id)))
|
||||
(if (some? data)
|
||||
(let [changes? (fn [id]
|
||||
(not= (get old-objects id)
|
||||
(get new-objects id)))
|
||||
|
||||
changed-ids (into #{}
|
||||
(filter changes?)
|
||||
(set/union (keys old-objects)
|
||||
(keys new-objects)))
|
||||
changed-ids (into #{}
|
||||
(filter changes?)
|
||||
(set/union (keys old-objects)
|
||||
(keys new-objects)))
|
||||
|
||||
shapes (->> changed-ids (mapv #(get new-objects %)) (filterv (comp not nil?)))
|
||||
parents-index (cp/generate-child-all-parents-index new-objects shapes)
|
||||
masks-index (cp/create-mask-index new-objects parents-index)
|
||||
shapes (->> changed-ids (mapv #(get new-objects %)) (filterv (comp not nil?)))
|
||||
parents-index (cp/generate-child-all-parents-index new-objects shapes)
|
||||
masks-index (cp/create-mask-index new-objects parents-index)
|
||||
|
||||
new-index (qdt/remove-all index changed-ids)
|
||||
new-index (qdt/remove-all index changed-ids)
|
||||
|
||||
index (reduce (index-shape new-objects parents-index masks-index)
|
||||
new-index
|
||||
shapes)
|
||||
index (reduce (index-shape new-objects parents-index masks-index)
|
||||
new-index
|
||||
shapes)
|
||||
|
||||
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
|
||||
[{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 $
|
||||
(reduce add-frames $ frames-to-add)
|
||||
(reduce add-data $ to-add)
|
||||
(reduce delete-data $ to-delete)
|
||||
(reduce delete-frames $ frames-to-delete))
|
||||
]
|
||||
|
||||
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))))
|
||||
|
||||
(defn- log-state
|
||||
"Helper function to print a friendly version of the snap tree. Debugging purposes"
|
||||
|
|
Loading…
Add table
Reference in a new issue