Skip to content

Commit

Permalink
added error handling for update notification, closes #18
Browse files Browse the repository at this point in the history
  • Loading branch information
dvcrn committed Nov 10, 2015
1 parent d78fd3d commit 6823da8
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/cljs/markright/main.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,21 @@
(defn check-update! []
;; xhr call
;; https://raw.githubusercontent.com/dvcrn/markright/master/node/package.json
(.end
(.request https #js {:host "raw.githubusercontent.com"
:path "/dvcrn/markright/master/node/package.json"
:port 443}
(fn [response]
(let [data (atom {:data (str "")})]
(.on response "data" #(swap! data assoc :data (str (@data :data) %)))
(.on response "end" (fn []
(let [remote-package (JSON/parse (@data :data))
latest-version (.-version remote-package)]
(if (is-newer? latest-version (.getVersion app))
(if (= (update-dialog @*win* (.getVersion app) latest-version) 1)
(.openExternal shell "https://github.com/dvcrn/markright/releases/latest")))))))))))
(let [request (.request https #js {:host "raw.githubusercontent.com"
:path "/dvcrn/markright/master/node/package.json"
:port 443}
(fn [response]
(let [data (atom {:data (str "")})]
(.on response "data" #(swap! data assoc :data (str (@data :data) %)))
(.on response "end" (fn []
(let [remote-package (JSON/parse (@data :data))
latest-version (.-version remote-package)]
(if (is-newer? latest-version (.getVersion app))
(if (= (update-dialog @*win* (.getVersion app) latest-version) 1)
(.openExternal shell "https://github.com/dvcrn/markright/releases/latest")))))))))]
(.on request "error" #(.log js/console "Couldn't check for update."))
(.end request)
))

(defn main []
(.start crash-reporter)
Expand Down

0 comments on commit 6823da8

Please sign in to comment.