mirror of
https://github.com/penpot/penpot.git
synced 2025-05-29 18:06:10 +02:00
⚡ Avoid double id lookup when calling lookup-page-objects (#6513)
This commit is contained in:
parent
71bb2556f9
commit
fd89c9d82c
3 changed files with 11 additions and 10 deletions
|
@ -395,7 +395,7 @@
|
||||||
(watch [it state _]
|
(watch [it state _]
|
||||||
(let [file-id (:current-file-id state)
|
(let [file-id (:current-file-id state)
|
||||||
page-id (:current-page-id state)
|
page-id (:current-page-id state)
|
||||||
objects (dsh/lookup-page-objects state page-id)
|
objects (dsh/lookup-page-objects state file-id page-id)
|
||||||
shapes (dwg/shapes-for-grouping objects selected)
|
shapes (dwg/shapes-for-grouping objects selected)
|
||||||
parents (into #{} (map :parent-id) shapes)]
|
parents (into #{} (map :parent-id) shapes)]
|
||||||
(when-not (empty? shapes)
|
(when-not (empty? shapes)
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
(ns app.main.data.workspace.path.changes
|
(ns app.main.data.workspace.path.changes
|
||||||
(:require
|
(:require
|
||||||
|
[app.common.data.macros :as dm]
|
||||||
[app.common.files.changes-builder :as pcb]
|
[app.common.files.changes-builder :as pcb]
|
||||||
[app.common.types.path :as path]
|
[app.common.types.path :as path]
|
||||||
[app.main.data.changes :as dch]
|
[app.main.data.changes :as dch]
|
||||||
|
@ -74,10 +75,10 @@
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state _]
|
(watch [it state _]
|
||||||
(let [objects (dsh/lookup-page-objects state)
|
(let [page-id (:current-page-id state)
|
||||||
page-id (:current-page-id state)
|
objects (dsh/lookup-page-objects state page-id)
|
||||||
id (get-in state [:workspace-local :edition])
|
id (dm/get-in state [:workspace-local :edition])
|
||||||
old-content (get-in state [:workspace-local :edit-path id :old-content])
|
old-content (dm/get-in state [:workspace-local :edit-path id :old-content])
|
||||||
shape (st/get-path state)]
|
shape (st/get-path state)]
|
||||||
|
|
||||||
(if (and (some? old-content) (some? (:id shape)))
|
(if (and (some? old-content) (some? (:id shape)))
|
||||||
|
|
|
@ -332,11 +332,11 @@
|
||||||
(ptk/reify ::select-shapes-by-current-selrect
|
(ptk/reify ::select-shapes-by-current-selrect
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ state _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (dsh/lookup-page-objects state)
|
objects (dsh/lookup-page-objects state page-id)
|
||||||
selrect (dm/get-in state [:workspace-local :selrect])
|
selrect (dm/get-in state [:workspace-local :selrect])
|
||||||
blocked? (fn [id] (dm/get-in objects [id :blocked] false))
|
blocked? (fn [id] (dm/get-in objects [id :blocked] false))
|
||||||
ask-worker (if buffered? mw/ask-buffered! mw/ask!)
|
ask-worker (if buffered? mw/ask-buffered! mw/ask!)
|
||||||
filter-objs (comp
|
filter-objs (comp
|
||||||
(filter (complement blocked?))
|
(filter (complement blocked?))
|
||||||
(remove (partial cfh/hidden-parent? objects)))]
|
(remove (partial cfh/hidden-parent? objects)))]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue