download latest nightly in desktop

Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
Andrey Shovkoplyas 2018-10-09 17:00:07 +02:00
parent c5d2852c5b
commit aaa8530f5a
No known key found for this signature in database
GPG Key ID: EAAB7C8622D860A4
4 changed files with 42 additions and 7 deletions

View File

@ -4,7 +4,14 @@
(handlers/register-handler-fx
:show-desktop-tab
(fn [{:keys [db] :as cofx} [_ tab-name]]
{:db (assoc-in db [:desktop/desktop :tab-view-id] tab-name)
:dispatch [:navigate-to (if (and (= tab-name :home) (:current-chat-id db))
:chat
:home)]}))
(merge {:db (assoc-in db [:desktop/desktop :tab-view-id] tab-name)
:dispatch [:navigate-to (if (and (= tab-name :home) (:current-chat-id db))
:chat
:home)]}
(when (= tab-name :profile)
{:http-get
{:url
"https://raw.githubusercontent.com/status-im/status-im.github.io/develop/env.sh"
:success-event-creator
(fn [o]
[:fetch-desktop-version-success o])}}))))

View File

@ -105,8 +105,10 @@
(views/defview profile [{:keys [seed-backed-up? mnemonic] :as user}]
(views/letsubs [current-view-id [:get :view-id]
nightly-version [:get-in [:desktop/desktop :nightly-version]]
editing? [:get :my-profile/editing?]] ;; TODO janherich: refactor my-profile, unnecessary complicated structure in db (could be just `:staged-name`/`:editing?` fields in account map) and horrible way to access it woth `:get`/`:set` subs/events
(let [adv-settings-open? (= current-view-id :advanced-settings)
(let [{:keys [url commit]} nightly-version
adv-settings-open? (= current-view-id :advanced-settings)
backup-recovery-phrase-open? (= current-view-id :backup-recovery-phrase)
show-backup-seed? (and (not seed-backed-up?) (not (string/blank? mnemonic)))]
[react/view
@ -137,7 +139,14 @@
[react/view {:style (styles/profile-row false)}
[react/touchable-highlight {:on-press #(re-frame/dispatch [:accounts.logout.ui/logout-confirmed])}
[react/text {:style (styles/profile-row-text colors/red)} (i18n/label :t/logout)]]
[react/view [react/text {:style (styles/profile-row-text colors/gray)} "V" build/version " (" build/commit-sha ")"]]]]])))
[react/view [react/text {:style (styles/profile-row-text colors/gray)} "V" build/version " (" build/commit-sha ")"]]]
(when (and url commit (not= (subs build/commit-sha 0 6) commit))
[react/view {:style {:margin-top 20}}
[react/touchable-highlight {:on-press #(.openURL react/linking url)}
[react/view {:style styles/share-contact-code}
[react/view {:style styles/share-contact-code-text-container}
[react/text {:style styles/share-contact-code-text}
(str "Download latest " commit)]]]]])]])))
(views/defview profile-data []
(views/letsubs

View File

@ -31,7 +31,10 @@
[status-im.utils.handlers :as handlers]
[status-im.utils.http :as http]
[status-im.utils.utils :as utils]
[status-im.utils.fx :as fx]))
[status-im.utils.fx :as fx]
[status-im.utils.platform :as platform]
[taoensso.timbre :as log]
[clojure.string :as str]))
(defn- http-get [{:keys [url response-validator success-event-creator failure-event-creator timeout-ms]}]
(let [on-success #(re-frame/dispatch (success-event-creator %))
@ -144,3 +147,16 @@
:update-window-dimensions
(fn [{:keys [db]} [_ dimensions]]
{:db (assoc db :dimensions/window (dimensions/window dimensions))}))
(handlers/register-handler-fx
:fetch-desktop-version-success
(fn [{:keys [db]} [_ result]]
(when (and result (not (str/blank? result)) (or platform/isMacOs? platform/isNix?))
(let [lines (str/split-lines result)
var (if platform/isMacOs? "DMG_URL=\"" "NIX_URL=\"")
param (first (filter #(not= -1 (.indexOf % var)) lines))]
(when param
(let [url (subs param (+ 9 (.indexOf param var)) (- (count param) 1))
dt (- (count url) (if platform/isMacOs? 12 17))
commit (subs url (- dt 6) dt)]
{:db (assoc-in db [:desktop/desktop :nightly-version] {:url url :commit commit})}))))))

View File

@ -21,6 +21,9 @@
(def mobile? (not= os "desktop"))
(def iphone-x? (and ios? (ios/iphone-x-dimensions?)))
(def isMacOs? (when platform (.-isMacOs platform)))
(def isNix? (when platform (or (.-isLinux platform) (.-isUnix platform))))
(def platform-specific
(cond
android? android/platform-specific