Skip to content

Commit af6f7cb

Browse files
committed
enhance performance
1 parent 72e1d34 commit af6f7cb

File tree

4 files changed

+27
-13
lines changed

4 files changed

+27
-13
lines changed

src/renderer/document/handlers.cljs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,17 @@
1111
[renderer.snap.handlers :as snap.handlers]
1212
[renderer.utils.vec :as utils.vec]))
1313

14-
(m/=> path [:-> App [:* [:or keyword? uuid?]] vector?])
14+
(m/=> path [:function
15+
[:-> App vector?]
16+
[:-> App keyword? vector?]
17+
[:-> App keyword? [:* any?] vector?]])
1518
(defn path
16-
[db & more]
17-
(apply conj [:documents (:active-document db)] more))
19+
([db]
20+
[:documents (:active-document db)])
21+
([db k]
22+
(conj (path db) k))
23+
([db k & more]
24+
(apply conj (path db) k more)))
1825

1926
(m/=> active [:-> App Document])
2027
(defn active

src/renderer/element/handlers.cljs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,7 @@
250250
(m/=> update-prop [:-> App uuid? ifn? [:* any?] App])
251251
(defn update-prop
252252
[db id k & more]
253-
(-> (apply update-in db (path db id k) more)
254-
(refresh-bbox id)))
253+
(apply update-in db (path db id k) more))
255254

256255
(m/=> assoc-prop [:function
257256
[:-> App keyword? any? App]
@@ -260,10 +259,9 @@
260259
([db k v]
261260
(reduce (partial-right assoc-prop k v) db (selected-ids db)))
262261
([db id k v]
263-
(-> (if (string/blank? v)
264-
(update-in db (path db id) dissoc k)
265-
(assoc-in db (path db id k) v))
266-
(refresh-bbox id))))
262+
(if (string/blank? v)
263+
(update-in db (path db id) dissoc k)
264+
(assoc-in db (path db id k) v))))
267265

268266
(m/=> dissoc-attr [:function
269267
[:-> App keyword? App]
@@ -274,7 +272,8 @@
274272
([db id k]
275273
(cond-> db
276274
(not (locked? db id))
277-
(update-prop id :attrs dissoc k))))
275+
(-> (update-prop id :attrs dissoc k)
276+
(refresh-bbox id)))))
278277

279278
(m/=> assoc-attr [:function
280279
[:-> App keyword? string? App]

src/renderer/element/impl/text.cljs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
(-> (element.handlers/delete db id)
6969
(history.handlers/finalize "Remove text"))
7070
(-> (element.handlers/assoc-prop db id :content s)
71+
(element.handlers/refresh-bbox id)
7172
(history.handlers/finalize "Set text")))
7273
(tool.handlers/activate :transform))))
7374

src/renderer/history/handlers.cljs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,17 @@
1212
[renderer.utils.math :refer [Vec2]]
1313
[renderer.utils.vec :as utils.vec]))
1414

15-
(m/=> path [:-> App [:* [:or keyword? uuid?]] vector?])
15+
(m/=> path [:function
16+
[:-> App vector?]
17+
[:-> App keyword? vector?]
18+
[:-> App keyword? [:* any?] vector?]])
1619
(defn path
17-
[db & more]
18-
(apply conj [:documents (:active-document db) :history] more))
20+
([db]
21+
[:documents (:active-document db) :history])
22+
([db k]
23+
(conj (path db) k))
24+
([db k & more]
25+
(apply conj (path db) k more)))
1926

2027
(m/=> history [:-> App [:maybe History]])
2128
(defn history

0 commit comments

Comments
 (0)