Skip to content

Commit 86e2b05

Browse files
committed
revert linter related changes
1 parent 88358b3 commit 86e2b05

File tree

11 files changed

+217
-174
lines changed

11 files changed

+217
-174
lines changed

src/electron/file.cljs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@
4444
(let [document (edn/read-string data)
4545
file-path (:path document)
4646
directory (and file-path (.dirname path file-path))
47-
options (-> (cond-> dialog-options
48-
(and directory (.existsSync fs directory))
49-
(assoc :defaultPath directory))
50-
(update :defaultPath #(.join path % (:title document))))]
47+
options (cond-> dialog-options
48+
(and directory (.existsSync fs directory))
49+
(assoc :defaultPath directory)
50+
51+
:always
52+
(update :defaultPath #(.join path % (:title document))))]
5153
(-> (save-dialog! options)
5254
(.then (fn [file-path]
5355
(when file-path

src/renderer/document/events.cljs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,11 @@
188188
(let [migrated-document (utils.compatibility/migrate-document document)
189189
migrated (not= document migrated-document)
190190
document (assoc migrated-document :id guid)]
191-
{:db (cond-> (-> db
192-
(document.handlers/load document)
193-
(history.handlers/finalize #(t [::load-doc "Load document"])))
191+
{:db (cond-> db
192+
:always
193+
(-> (document.handlers/load document)
194+
(history.handlers/finalize #(t [::load-doc "Load document"])))
195+
194196
(not migrated)
195197
(document.handlers/update-saved-info (select-keys
196198
document

src/renderer/document/handlers.cljs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,16 @@
181181
open-document-id
182182
(assoc :id open-document-id))]
183183
(if (document.db/valid? document)
184-
(-> (cond-> db
185-
(not open-document-id)
186-
(-> (create-tab document)
187-
(center))
184+
(cond-> db
185+
(not open-document-id)
186+
(-> (create-tab document)
187+
(center))
188188

189-
(:path document)
190-
(add-recent (:path document)))
189+
(:path document)
190+
(add-recent (:path document))
191191

192-
(set-active (:id document)))
192+
:always
193+
(set-active (:id document)))
193194

194195
(let [explanation (-> document document.db/explain m.error/humanize str)]
195196
(->> (notification.views/spec-failed "Load document" explanation)

src/renderer/element/handlers.cljs

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -662,13 +662,15 @@
662662
(m/=> normalize [:-> map? Element])
663663
(defn normalize
664664
[el]
665-
(-> (cond-> el
666-
(not (string? (:content el)))
667-
(dissoc :content))
668-
(utils.map/remove-nils)
669-
(utils.element/normalize-attrs)
670-
(dissoc :locked)
671-
(merge db/default)))
665+
(cond-> el
666+
(not (string? (:content el)))
667+
(dissoc :content)
668+
669+
:always
670+
(-> (utils.map/remove-nils)
671+
(utils.element/normalize-attrs)
672+
(dissoc :locked)
673+
(merge db/default))))
672674

673675
(m/=> create [:-> App map? App])
674676
(defn create
@@ -688,28 +690,33 @@
688690
(let [error-message (-> new-el db/explain m.error/humanize str)]
689691
(->> (notification.views/spec-failed "Invalid element" error-message)
690692
(notification.handlers/add db)))
691-
(cond-> (assoc-in db (path db id) new-el)
692-
(:parent new-el)
693-
(update-prop (:parent new-el) :children #(vec (conj % id)))
693+
(let [is-translated (or (utils.element/svg? new-el)
694+
(utils.element/root? new-el)
695+
(:parent el))]
696+
(cond-> db
697+
:always
698+
(assoc-in (path db id) new-el)
699+
700+
(:parent new-el)
701+
(update-prop (:parent new-el) :children #(vec (conj % id)))
694702

695-
(not (or (utils.element/svg? new-el)
696-
(utils.element/root? new-el)
697-
(:parent el)))
698-
(translate [(- min-x) (- min-y)])
703+
(not is-translated)
704+
(translate [(- min-x) (- min-y)])
699705

700-
(or (utils.element/svg? new-el)
701-
(utils.element/root? new-el)
702-
(:parent el))
703-
(refresh-bbox id)
706+
is-translated
707+
(refresh-bbox id)
704708

705-
child-els
706-
(add-children child-els)))))
709+
child-els
710+
(add-children child-els))))))
707711

708712
(m/=> create-default-canvas [:-> App [:maybe Vec2] App])
709713
(defn create-default-canvas
710714
[db size]
711-
(cond-> (create db {:tag :canvas
712-
:attrs {:fill "#eeeeee"}})
715+
(cond-> db
716+
:always
717+
(create {:tag :canvas
718+
:attrs {:fill "#eeeeee"}})
719+
713720
size
714721
(-> (create {:tag :svg
715722
:attrs {:width (first size)
@@ -771,9 +778,12 @@
771778
pointer-pos (:adjusted-pointer-pos db)]
772779
(reduce
773780
select
774-
(cond-> (-> (deselect db)
775-
(add (assoc el :parent (:id parent-el)))
776-
(place (matrix/add pointer-pos offset)))
781+
(cond-> db
782+
:always
783+
(-> (deselect)
784+
(add (assoc el :parent (:id parent-el)))
785+
(place (matrix/add pointer-pos offset)))
786+
777787
(not= (:id (root db)) (:id parent-el))
778788
(translate [(- s-x1) (- s-y1)])) (selected-ids db)))))
779789

src/renderer/element/impl/container/svg.cljs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@
4848
:style {:filter (str "blur(" (/ 2 zoom) "px)")}})]
4949

5050
[:svg
51-
(cond-> (dissoc attrs :style)
51+
(cond-> attrs
52+
:always
53+
(dissoc :style)
54+
5255
active-filter
5356
(assoc :filter (str "url(#" (name active-filter) ")")))
5457
[:rect

src/renderer/element/impl/shape/rect.cljs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@
3434
rx (if (> rx (/ width 2)) (/ width 2) rx)
3535
ry (if (> ry (/ height 2)) (/ height 2) ry)
3636
curved? (and (> rx 0) (> ry 0))]
37-
(-> []
38-
(conj "M" (+ x rx) y)
39-
(conj "H" (- (+ x width) rx))
40-
(cond-> curved? (conj "A" rx ry 0 0 1 (+ x width) (+ y ry)))
41-
(conj "V" (- (+ y height) ry))
42-
(cond-> curved? (conj "A" rx ry 0 0 1 (- (+ x width) rx) (+ y height)))
43-
(conj "H" (+ x rx))
44-
(cond-> curved? (conj "A" rx ry 0 0 1 x (- (+ y height) ry)))
45-
(conj "V" (+ y ry))
46-
(cond-> curved? (conj "A" rx ry 0 0 1 (+ x rx) y))
47-
(conj "z")
48-
(->> (string/join " ")))))
37+
(cond-> []
38+
:always (conj "M" (+ x rx) y
39+
"H" (- (+ x width) rx))
40+
curved? (conj "A" rx ry 0 0 1 (+ x width) (+ y ry))
41+
:always (conj "V" (- (+ y height) ry))
42+
curved? (conj "A" rx ry 0 0 1 (- (+ x width) rx) (+ y height))
43+
:always (conj "H" (+ x rx))
44+
curved? (conj "A" rx ry 0 0 1 x (- (+ y height) ry))
45+
:always (conj "V" (+ y ry))
46+
curved? (conj "A" rx ry 0 0 1 (+ x rx) y)
47+
:always (conj "z")
48+
:always (->> (string/join " ")))))

src/renderer/event/handlers.cljs

Lines changed: 73 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -32,56 +32,60 @@
3232
"pointermove"
3333
(-> (if pointer-offset
3434
(if (significant-drag? pointer-pos pointer-offset drag-threshold)
35-
(-> (cond-> db
36-
(not= tool :pan)
37-
(tool.handlers/pan-out-of-canvas dom-rect pointer-pos pointer-offset)
38-
39-
(not drag)
40-
(-> (assoc :drag true)
41-
(tool.hierarchy/on-drag-start e)
42-
(tool.handlers/add-fx [::event.effects/set-pointer-capture
43-
pointer-id])))
44-
(tool.hierarchy/on-drag e))
35+
(cond-> db
36+
(not= tool :pan)
37+
(tool.handlers/pan-out-of-canvas dom-rect pointer-pos pointer-offset)
38+
39+
(not drag)
40+
(-> (assoc :drag true)
41+
(tool.hierarchy/on-drag-start e)
42+
(tool.handlers/add-fx [::event.effects/set-pointer-capture
43+
pointer-id]))
44+
45+
:always
46+
(tool.hierarchy/on-drag e))
4547
db)
4648
(tool.hierarchy/on-pointer-move db e))
4749
(assoc :pointer-pos pointer-pos
4850
:adjusted-pointer-pos adjusted-pointer-pos))
4951

5052
"pointerdown"
51-
(-> (cond-> db
52-
(= button :middle)
53-
(-> (assoc :cached-tool tool
54-
:cached-state state)
55-
(tool.handlers/activate :pan))
53+
(cond-> db
54+
(= button :middle)
55+
(-> (assoc :cached-tool tool
56+
:cached-state state)
57+
(tool.handlers/activate :pan))
5658

57-
(not= button :right)
58-
(-> (update :active-pointers conj pointer-id)
59-
(assoc :pointer-offset pointer-pos
60-
:adjusted-pointer-offset adjusted-pointer-pos
61-
:nearest-neighbor-offset (:point nearest-neighbor))))
62-
63-
(tool.hierarchy/on-pointer-down e)
64-
(tool.handlers/add-fx [::effects/focus nil]))
59+
(not= button :right)
60+
(-> (update :active-pointers conj pointer-id)
61+
(assoc :pointer-offset pointer-pos
62+
:adjusted-pointer-offset adjusted-pointer-pos
63+
:nearest-neighbor-offset (:point nearest-neighbor)))
64+
:always
65+
(-> (tool.hierarchy/on-pointer-down e)
66+
(tool.handlers/add-fx [::effects/focus nil])))
6567

6668
"pointerup"
6769
(if (contains? active-pointers pointer-id)
68-
(-> (cond-> (if drag
69-
(-> (tool.hierarchy/on-drag-end db e)
70-
(tool.handlers/add-fx [::event.effects/release-pointer-capture
71-
pointer-id]))
72-
(if (= button :right)
73-
db
74-
(if (< 0 (- timestamp event-timestamp) double-click-delta)
75-
(-> (dissoc db :event-timestamp)
76-
(tool.hierarchy/on-double-click e))
77-
(-> (assoc db :event-timestamp timestamp)
78-
(tool.hierarchy/on-pointer-up e)))))
79-
(and cached-tool (= button :middle))
80-
(-> (tool.handlers/activate cached-tool)
81-
(tool.handlers/set-state cached-state)
82-
(dissoc :cached-tool :cached-state)))
83-
(update :active-pointers disj pointer-id)
84-
(dissoc :pointer-offset :drag :nearest-neighbor))
70+
(cond-> (if drag
71+
(-> (tool.hierarchy/on-drag-end db e)
72+
(tool.handlers/add-fx [::event.effects/release-pointer-capture
73+
pointer-id]))
74+
(if (= button :right)
75+
db
76+
(if (< 0 (- timestamp event-timestamp) double-click-delta)
77+
(-> (dissoc db :event-timestamp)
78+
(tool.hierarchy/on-double-click e))
79+
(-> (assoc db :event-timestamp timestamp)
80+
(tool.hierarchy/on-pointer-up e)))))
81+
(and cached-tool (= button :middle))
82+
(-> (tool.handlers/activate cached-tool)
83+
(tool.handlers/set-state cached-state)
84+
(dissoc :cached-tool :cached-state))
85+
86+
:always
87+
(-> (update :active-pointers disj pointer-id)
88+
(dissoc :pointer-offset :drag :nearest-neighbor)))
8589
db)
8690
db)))
8791

@@ -90,33 +94,37 @@
9094
[db e]
9195
(case (:type e)
9296
"keydown"
93-
(-> (cond-> db
94-
(and (= (:code e) "Space")
95-
(not= (:tool db) :pan)
96-
(= (:state db) :idle))
97-
(-> (assoc :cached-tool (:tool db))
98-
(tool.handlers/activate :pan))
99-
100-
(= (:key e) "Shift")
101-
(-> (assoc-in [:snap :transient-active] true)
102-
(cond-> (not (-> db :snap :active))
103-
(-> (dissoc :nearest-neighbor)
104-
(snap.handlers/rebuild-tree)))))
105-
(tool.hierarchy/on-key-down e))
97+
(cond-> db
98+
(and (= (:code e) "Space")
99+
(not= (:tool db) :pan)
100+
(= (:state db) :idle))
101+
(-> (assoc :cached-tool (:tool db))
102+
(tool.handlers/activate :pan))
103+
104+
(= (:key e) "Shift")
105+
(-> (assoc-in [:snap :transient-active] true)
106+
(cond-> (not (-> db :snap :active))
107+
(-> (dissoc :nearest-neighbor)
108+
(snap.handlers/rebuild-tree))))
109+
110+
:always
111+
(tool.hierarchy/on-key-down e))
106112

107113
"keyup"
108-
(-> (cond-> db
109-
(and (= (:code e) "Space")
110-
(:cached-tool db))
111-
(-> (tool.handlers/activate (:cached-tool db))
112-
(dissoc :cached-tool))
113-
114-
(= (:key e) "Shift")
115-
(-> (assoc-in [:snap :transient-active] false)
116-
(cond->
117-
(not (-> db :snap :active))
118-
(dissoc :nearest-neighbor))))
119-
(tool.hierarchy/on-key-up e))
114+
(cond-> db
115+
(and (= (:code e) "Space")
116+
(:cached-tool db))
117+
(-> (tool.handlers/activate (:cached-tool db))
118+
(dissoc :cached-tool))
119+
120+
(= (:key e) "Shift")
121+
(-> (assoc-in [:snap :transient-active] false)
122+
(cond->
123+
(not (-> db :snap :active))
124+
(dissoc :nearest-neighbor)))
125+
126+
:always
127+
(tool.hierarchy/on-key-up e))
120128
db))
121129

122130
(m/=> wheel [:-> App WheelEvent App])

0 commit comments

Comments
 (0)