Skip to content

Commit 3c92c69

Browse files
committed
fix style
1 parent 516c756 commit 3c92c69

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

src/electron/file.cljs

+14-14
Original file line numberDiff line numberDiff line change
@@ -19,56 +19,56 @@
1919
:path file-path
2020
:title (.basename path file-path))))
2121

22-
(defn- write-file
22+
(defn- write-file!
2323
[file-path data]
2424
(.writeFileSync fs file-path (pr-str (dissoc data :closing? :path)) "utf-8")
2525
(p/resolved (serialize-document data file-path)))
2626

27-
(defn- read-file
27+
(defn- read-file!
2828
[file-path]
2929
(let [data (.readFileSync fs file-path "utf-8")
3030
document (edn/read-string data)]
3131
(serialize-document document file-path)))
3232

33-
(defn save-dialog
33+
(defn save-dialog!
3434
[window options]
3535
(p/let [file (.showSaveDialog dialog window (clj->js options))
3636
file (get (js->clj file) "filePath")]
3737
(p/resolved file)))
3838

39-
(defn save-as
39+
(defn save-as!
4040
[window data]
4141
(let [document (edn/read-string data)
4242
file-path (:path document)
4343
directory (and file-path (.dirname path file-path))
4444
dialog-options (cond-> dialog-options
4545
(and directory (.existsSync fs directory))
4646
(assoc :defaultPath directory))]
47-
(p/let [file (save-dialog window dialog-options)]
48-
(write-file file document))))
47+
(p/let [file (save-dialog! window dialog-options)]
48+
(write-file! file document))))
4949

50-
(defn save
50+
(defn save!
5151
[window data]
5252
(let [document (edn/read-string data)
5353
file-path (:path document)]
5454
(if (and file-path (.existsSync fs file-path))
55-
(write-file file-path document)
56-
(save-as window data))))
55+
(write-file! file-path document)
56+
(save-as! window data))))
5757

58-
(defn open
58+
(defn open!
5959
[window file-path]
6060
(if (and file-path (.existsSync fs file-path))
61-
[(read-file file-path)]
61+
[(read-file! file-path)]
6262
(p/let [files (.showOpenDialog dialog window (clj->js dialog-options))
6363
file-paths (get (js->clj files) "filePaths")]
64-
(p/resolved (map read-file file-paths)))))
64+
(p/resolved (map read-file! file-paths)))))
6565

6666
(def export-options
6767
{:defaultPath (.getPath app "pictures")
6868
:filters [{:name "svg"
6969
:extensions ["svg" "svgo"]}]})
7070

71-
(defn export
71+
(defn export!
7272
[window data]
73-
(p/let [file (save-dialog window export-options)]
73+
(p/let [file (save-dialog! window export-options)]
7474
(.writeFileSync fs file data "utf-8")))

src/electron/main.cljs

+20-20
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
(.then (fn [name] (js/console.log "Added Extension: " name)))
2525
(.catch (fn [err] (js/console.log "An error occurred: " err)))))
2626

27-
(defn send-to-renderer
27+
(defn send-to-renderer!
2828
([action]
29-
(send-to-renderer action nil))
29+
(send-to-renderer! action nil))
3030
([action data]
3131
(-> (.-webContents ^js @main-window)
3232
(.send "fromMain" (clj->js {:action action
@@ -42,7 +42,7 @@
4242
[url]
4343
(contains? allowed-urls (.-host url)))
4444

45-
(defn open-external
45+
(defn open-external!
4646
[url]
4747
(let [url-parsed (js/URL. url)]
4848
(when (and (= (.-protocol url-parsed) "https:") (allowed-url? url-parsed))
@@ -55,14 +55,14 @@
5555
"windowToggleMaximized" (if (.isMaximized ^js @main-window) (.unmaximize ^js @main-window) (.maximize ^js @main-window))
5656
"windowToggleFullscreen" (.setFullScreen ^js @main-window (not (.isFullScreen ^js @main-window)))
5757
"setThemeMode" (set! (.. nativeTheme -themeSource) (.-data args))
58-
"openRemoteUrl" (open-external (.-data args))
58+
"openRemoteUrl" (open-external! (.-data args))
5959
;; https://www.electronjs.org/docs/api/clipboard#clipboardwritedata-type
6060
"writeToClipboard" (.write clipboard (.-data args))
6161
"openDirectory" (.showItemInFolder shell (.-data args))
62-
"openDocument" (p/let [documents (file/open @main-window (.-data args))] (doseq [document documents] (send-to-renderer "fileLoaded" document)))
63-
"saveDocument" (p/let [document (file/save @main-window (.-data args))] (send-to-renderer "fileSaved" document))
64-
"saveDocumentAs" (p/let [document (file/save-as @main-window (.-data args))] (send-to-renderer "fileSaved" document))
65-
"export" (file/export @main-window (.-data args))))
62+
"openDocument" (p/let [documents (file/open! @main-window (.-data args))] (doseq [document documents] (send-to-renderer! "fileLoaded" document)))
63+
"saveDocument" (p/let [document (file/save! @main-window (.-data args))] (send-to-renderer! "fileSaved" document))
64+
"saveDocumentAs" (p/let [document (file/save-as! @main-window (.-data args))] (send-to-renderer! "fileSaved" document))
65+
"export" (file/export! @main-window (.-data args))))
6666

6767
(defn register-window-events!
6868
[]
@@ -77,7 +77,7 @@
7777
["leave-full-screen" "windowLeavedFullscreen"]
7878
["minimize" "windowMinimized"]
7979
["restore" "windowRestored"]]]
80-
(.on ^js @main-window window-event #(send-to-renderer action))))
80+
(.on ^js @main-window window-event #(send-to-renderer! action))))
8181

8282
(defn register-web-contents-events!
8383
[]
@@ -88,10 +88,10 @@
8888
(.on (.-webContents ^js @main-window) web-contents-event f))
8989
;; Forward popups
9090
(.setWindowOpenHandler (.-webContents ^js @main-window) (fn [handler]
91-
(open-external (.-url handler))
91+
(open-external! (.-url handler))
9292
#js {:action "deny"})))
9393

94-
(defn init-main-window
94+
(defn init-main-window!
9595
[]
9696
(let [win-state (window-state-keeper #js {:defaultWidth 1920
9797
:defaultHeight 1080})]
@@ -115,12 +115,12 @@
115115
(fn []
116116
(.show ^js @main-window)
117117
(.manage win-state ^js @main-window)
118-
(send-to-renderer (if (.isMaximized ^js @main-window)
119-
"windowMaximized"
120-
"windowUnmaximized"))
121-
(send-to-renderer (if (.isFullScreen ^js @main-window)
122-
"windowEnteredFullscreen"
123-
"windowLeavedFullscreen"))
118+
(send-to-renderer! (if (.isMaximized ^js @main-window)
119+
"windowMaximized"
120+
"windowUnmaximized"))
121+
(send-to-renderer! (if (.isFullScreen ^js @main-window)
122+
"windowEnteredFullscreen"
123+
"windowLeavedFullscreen"))
124124
(.hide ^js @loading-window)
125125
(.close ^js @loading-window)))
126126

@@ -138,7 +138,7 @@
138138

139139
#_(.checkForUpdatesAndNotify updater)))
140140

141-
(defn init-loading-window []
141+
(defn init-loading-window! []
142142
(set! (.-allowRendererProcessReuse app) false)
143143
(reset! loading-window
144144
(BrowserWindow.
@@ -148,7 +148,7 @@
148148
:icon (.join path js/__dirname "/public/img/icon.png")
149149
:show false
150150
:frame false}))
151-
(.once ^js @loading-window "show" init-main-window)
151+
(.once ^js @loading-window "show" init-main-window!)
152152
(.loadURL ^js @loading-window (.join path "file://" js/__dirname "/public/loading.html"))
153153
(.once ^js (.-webContents @loading-window) "did-finish-load" #(.show ^js @loading-window)))
154154

@@ -157,4 +157,4 @@
157157
(.initialize log)
158158
(.on app "window-all-closed" #(when-not (= js/process.platform "darwin")
159159
(.quit app)))
160-
(.on app "ready" init-loading-window))
160+
(.on app "ready" init-loading-window!))

0 commit comments

Comments
 (0)