Skip to content

Commit 6d3d64d

Browse files
committed
refactor
1 parent 008782b commit 6d3d64d

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

src/electron/file.cljs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
[file-path data]
2323
(let [document (pr-str (dissoc data :path :id :title))]
2424
(.writeFileSync fs file-path document "utf-8")
25-
(js/Promise.resolve (serialize-document (select-keys data [:id]) file-path))))
25+
(-> (select-keys data [:id])
26+
(serialize-document file-path)
27+
(js/Promise.resolve))))
2628

2729
(defn- read!
2830
[file-path]

src/renderer/frame/handlers.cljs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
(select-keys [:width :height]))]
4444
(if-not (-> db :window :focused)
4545
db
46-
(reduce #(pan-by %1 (mat/div [(:width offset) (:height offset)] 2) %2) db (:document-tabs db)))))
46+
(-> (:document-tabs db)
47+
(reduce #(pan-by %1 (mat/div [(:width offset) (:height offset)] 2) %2) db)))))
4748

4849
(m/=> zoom-in-place [:-> App number? Vec2D App])
4950
(defn zoom-in-place

src/renderer/history/handlers.cljs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@
9898
([db]
9999
(undo db 1))
100100
([db n]
101-
(if (and (pos? n) (undos? (history db)))
102-
(recur (go-to db (previous-position (history db))) (dec n))
103-
db)))
101+
(if-not (and (pos? n) (undos? (history db)))
102+
db
103+
(recur (go-to db (previous-position (history db))) (dec n)))))
104104

105105
(m/=> redo [:function
106106
[:-> App App]
@@ -109,9 +109,9 @@
109109
([db]
110110
(redo db 1))
111111
([db n]
112-
(if (and (pos? n) (redos? (history db)))
113-
(recur (go-to db (next-position (history db))) (dec n))
114-
db)))
112+
(if-not (and (pos? n) (redos? (history db)))
113+
db
114+
(recur (go-to db (next-position (history db))) (dec n)))))
115115

116116
(m/=> accumulate [:-> History [:or fn? keyword?] [:vector HistoryState]])
117117
(defn accumulate
@@ -177,12 +177,12 @@
177177
db db]
178178
(let [parent-id (:parent node)
179179
parent (state (history db) parent-id)]
180-
(if parent
180+
(if-not parent
181+
db
181182
(let [index (.indexOf (:children parent) (:id node))
182183
new-index (dec (count (:children parent)))
183184
children-path (path db :states parent-id :children)]
184-
(recur parent (update-in db children-path vec/move index new-index)))
185-
db))))
185+
(recur parent (update-in db children-path vec/move index new-index)))))))
186186

187187
(def valid-elements? (m/validator [:map-of uuid? Element]))
188188

src/renderer/utils/units.cljs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@
5050
(let [s (str/trim (str v))
5151
n (js/parseFloat s 10)
5252
unit (match-unit s)]
53-
[(if (js/isNaN n) 0 n)
54-
unit]))
53+
[(if (js/isNaN n) 0 n) unit]))
5554

5655
(m/=> ->px [:-> number? string? number?])
5756
(defn ->px

0 commit comments

Comments
 (0)