reformat status-im.ui.* namespaces
This commit is contained in:
parent
6c620728da
commit
6fc03fc217
|
@ -16,7 +16,6 @@
|
|||
:align-items :center
|
||||
:padding-horizontal 12})
|
||||
|
||||
|
||||
(defn- border [position]
|
||||
(let [radius (if platform/ios? 8 4)]
|
||||
(case position
|
||||
|
@ -53,7 +52,6 @@
|
|||
{:android {:opacity 0.4}
|
||||
:ios {:opacity 0.6}})
|
||||
|
||||
|
||||
(defstyle button-borders
|
||||
{:border-radius 8
|
||||
:ios {;; Border radius is ignored with transparent background unless overflow "hidden" is used
|
||||
|
@ -62,14 +60,14 @@
|
|||
|
||||
(def primary-button
|
||||
(merge
|
||||
button-borders
|
||||
{:background-color styles/color-blue4}))
|
||||
button-borders
|
||||
{:background-color styles/color-blue4}))
|
||||
|
||||
(def primary-button-text {:color styles/color-white})
|
||||
|
||||
(def secondary-button
|
||||
(merge
|
||||
button-borders
|
||||
{:background-color styles/color-blue4-transparent}))
|
||||
button-borders
|
||||
{:background-color styles/color-blue4-transparent}))
|
||||
|
||||
(def secondary-button-text {:color styles/color-blue4})
|
||||
|
|
|
@ -158,8 +158,8 @@
|
|||
[react/view (styles/profile-icon-mask size)])
|
||||
(when edit?
|
||||
[react/view (styles/profile-icon-edit-text-containter size)
|
||||
[react/text {:style styles/profile-icon-edit-text}
|
||||
(i18n/label :t/edit)]])
|
||||
[react/text {:style styles/profile-icon-edit-text}
|
||||
(i18n/label :t/edit)]])
|
||||
(if (and photo-path (seq photo-path))
|
||||
[chat-icon photo-path styles]
|
||||
[default-chat-icon name styles])]))
|
||||
|
|
|
@ -25,6 +25,6 @@
|
|||
r (js/parseInt (subs hex 0 2) 16)
|
||||
g (js/parseInt (subs hex 2 4) 16)
|
||||
b (js/parseInt (subs hex 4 6) 16)]
|
||||
(str "rgba(" r "," g "," b "," opacity")")))
|
||||
(str "rgba(" r "," g "," b "," opacity ")")))
|
||||
|
||||
(def text black)
|
||||
|
|
|
@ -91,12 +91,12 @@
|
|||
(defn image-contain [_ _]
|
||||
(let [content-width (reagent/atom 0)]
|
||||
(reagent/create-class
|
||||
{:reagent-render
|
||||
(fn [{:keys [container-style style]} {:keys [image width height]}]
|
||||
[react/view {:style (merge styles/image-contain container-style)
|
||||
:on-layout #(reset! content-width (-> % .-nativeEvent .-layout .-width))}
|
||||
[react/image {:source image
|
||||
:resize-mode :contain
|
||||
:style (merge style
|
||||
{:width @content-width
|
||||
:height (/ (* @content-width height) width)})}]])})))
|
||||
{:reagent-render
|
||||
(fn [{:keys [container-style style]} {:keys [image width height]}]
|
||||
[react/view {:style (merge styles/image-contain container-style)
|
||||
:on-layout #(reset! content-width (-> % .-nativeEvent .-layout .-width))}
|
||||
[react/image {:source image
|
||||
:resize-mode :contain
|
||||
:style (merge style
|
||||
{:width @content-width
|
||||
:height (/ (* @content-width height) width)})}]])})))
|
|
@ -110,14 +110,14 @@
|
|||
|
||||
(defn logo-container [size shadow?]
|
||||
(merge
|
||||
{:width size
|
||||
:height size
|
||||
:border-radius size
|
||||
:background-color colors/blue
|
||||
:align-items :center
|
||||
:justify-content :center}
|
||||
(when shadow?
|
||||
logo-shaddow)))
|
||||
{:width size
|
||||
:height size
|
||||
:border-radius size
|
||||
:background-color colors/blue
|
||||
:align-items :center
|
||||
:justify-content :center}
|
||||
(when shadow?
|
||||
logo-shaddow)))
|
||||
|
||||
(defn logo [icon-size]
|
||||
{:color :white
|
||||
|
@ -136,12 +136,12 @@
|
|||
|
||||
(defn button [style background?]
|
||||
(merge
|
||||
{:padding-vertical 12
|
||||
:padding-horizontal 42
|
||||
:border-radius 8}
|
||||
style
|
||||
(when background?
|
||||
{:background-color (colors/alpha colors/blue 0.1)})))
|
||||
{:padding-vertical 12
|
||||
:padding-horizontal 42
|
||||
:border-radius 8}
|
||||
style
|
||||
(when background?
|
||||
{:background-color (colors/alpha colors/blue 0.1)})))
|
||||
|
||||
(def button-label
|
||||
{:font-size 15
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
(defn start-error-animation [offline-opacity]
|
||||
(animation/start
|
||||
(animation/timing offline-opacity {:toValue 1.0
|
||||
:duration 250})))
|
||||
(animation/timing offline-opacity {:toValue 1.0
|
||||
:duration 250})))
|
||||
|
||||
(defn error-view [_]
|
||||
(let [offline? (re-frame/subscribe [:offline?])
|
||||
|
@ -24,18 +24,18 @@
|
|||
current-chat-contact (re-frame/subscribe [:get-current-chat-contact])
|
||||
view-id (re-frame/subscribe [:get :view-id])]
|
||||
(reagent/create-class
|
||||
{:component-did-mount
|
||||
on-update
|
||||
:component-did-update
|
||||
on-update
|
||||
:display-name "connectivity-error-view"
|
||||
:reagent-render
|
||||
(fn [{:keys [top]}]
|
||||
(when (or @offline? @connection-problem?)
|
||||
(let [pending? (and (:pending @current-chat-contact) (= :chat @view-id))]
|
||||
[react/animated-view {:style (styles/offline-wrapper top offline-opacity window-width pending?)}
|
||||
[react/view
|
||||
[react/text {:style styles/offline-text}
|
||||
(i18n/label (if @connection-problem?
|
||||
:t/connection-problem
|
||||
:t/offline))]]])))})))
|
||||
{:component-did-mount
|
||||
on-update
|
||||
:component-did-update
|
||||
on-update
|
||||
:display-name "connectivity-error-view"
|
||||
:reagent-render
|
||||
(fn [{:keys [top]}]
|
||||
(when (or @offline? @connection-problem?)
|
||||
(let [pending? (and (:pending @current-chat-contact) (= :chat @view-id))]
|
||||
[react/animated-view {:style (styles/offline-wrapper top offline-opacity window-width pending?)}
|
||||
[react/view
|
||||
[react/text {:style styles/offline-text}
|
||||
(i18n/label (if @connection-problem?
|
||||
:t/connection-problem
|
||||
:t/offline))]]])))})))
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
[chat-icon/contact-icon-contacts-tab contact]]
|
||||
[react/view styles/info-container
|
||||
[react/text (merge {:style styles/name-text
|
||||
:number-of-lines 1}
|
||||
:number-of-lines 1}
|
||||
(when dapp? {:accessibility-label :dapp-name})
|
||||
props)
|
||||
(if (pos? (count (:name contact)))
|
||||
|
@ -34,18 +34,18 @@
|
|||
[react/touchable-highlight (merge {:accessibility-label accessibility-label}
|
||||
(when-not extended?
|
||||
{:on-press (when on-press #(on-press contact))}))
|
||||
[react/view styles/contact-container
|
||||
[contact-inner-view {:contact contact :info info :style style :props inner-props}]
|
||||
(when show-forward?
|
||||
[react/view styles/forward-btn
|
||||
[vector-icons/icon :icons/forward]])
|
||||
(when (and extended? (not (empty? extend-options)))
|
||||
[react/view styles/more-btn-container
|
||||
[react/touchable-highlight {:on-press #(list-selection/show {:options extend-options
|
||||
:title extend-title})
|
||||
:accessibility-label :menu-option}
|
||||
[react/view styles/more-btn
|
||||
[vector-icons/icon :icons/options {:accessibility-label :options}]]]])]])
|
||||
[react/view styles/contact-container
|
||||
[contact-inner-view {:contact contact :info info :style style :props inner-props}]
|
||||
(when show-forward?
|
||||
[react/view styles/forward-btn
|
||||
[vector-icons/icon :icons/forward]])
|
||||
(when (and extended? (not (empty? extend-options)))
|
||||
[react/view styles/more-btn-container
|
||||
[react/touchable-highlight {:on-press #(list-selection/show {:options extend-options
|
||||
:title extend-title})
|
||||
:accessibility-label :menu-option}
|
||||
[react/view styles/more-btn
|
||||
[vector-icons/icon :icons/options {:accessibility-label :options}]]]])]])
|
||||
|
||||
(views/defview toogle-contact-view [{:keys [whisper-identity] :as contact} selected-key on-toggle-handler]
|
||||
(views/letsubs [checked [selected-key whisper-identity]]
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
(ns status-im.ui.components.desktop.views
|
||||
(:require
|
||||
[status-im.ui.components.icons.vector-icons :as icons]
|
||||
[status-im.ui.components.common.styles :as styles]
|
||||
[status-im.ui.components.action-button.styles :as st]
|
||||
[status-im.ui.components.styles :as common]
|
||||
[status-im.ui.components.checkbox.styles :as checkbox.styles]
|
||||
[status-im.ui.components.react :as react]))
|
||||
[status-im.ui.components.icons.vector-icons :as icons]
|
||||
[status-im.ui.components.common.styles :as styles]
|
||||
[status-im.ui.components.action-button.styles :as st]
|
||||
[status-im.ui.components.styles :as common]
|
||||
[status-im.ui.components.checkbox.styles :as checkbox.styles]
|
||||
[status-im.ui.components.react :as react]))
|
||||
|
||||
(defn checkbox [{:keys [on-value-change checked?]}]
|
||||
[react/touchable-highlight {:style checkbox.styles/wrapper :on-press #(do (when on-value-change (on-value-change (not checked?))))}
|
||||
|
|
|
@ -99,20 +99,20 @@
|
|||
:accessibility-label accessibility-label}
|
||||
(if-let [icon-fn (get icons (normalize-property-name name))]
|
||||
(let [icon-vec (icon-fn
|
||||
(cond
|
||||
(keyword? color)
|
||||
(case color
|
||||
:dark styles/icon-dark-color
|
||||
:gray styles/icon-gray-color
|
||||
:blue styles/color-light-blue
|
||||
:active styles/color-blue4
|
||||
:white styles/color-white
|
||||
:red styles/icon-red-color
|
||||
styles/icon-dark-color)
|
||||
(string? color)
|
||||
color
|
||||
:else
|
||||
styles/icon-dark-color))]
|
||||
(cond
|
||||
(keyword? color)
|
||||
(case color
|
||||
:dark styles/icon-dark-color
|
||||
:gray styles/icon-gray-color
|
||||
:blue styles/color-light-blue
|
||||
:active styles/color-blue4
|
||||
:white styles/color-white
|
||||
:red styles/icon-red-color
|
||||
styles/icon-dark-color)
|
||||
(string? color)
|
||||
color
|
||||
:else
|
||||
styles/icon-dark-color))]
|
||||
(if width
|
||||
(update icon-vec 1 assoc :width width :height height)
|
||||
icon-vec))
|
||||
|
|
|
@ -76,8 +76,8 @@
|
|||
|
||||
(def separator
|
||||
(merge
|
||||
base-separator
|
||||
{:margin-left 70}))
|
||||
base-separator
|
||||
{:margin-left 70}))
|
||||
|
||||
(defstyle list-header-footer-spacing
|
||||
{:android {:background-color colors/white
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
[vector-icons/icon icon (merge icon-opts {:style styles/item-icon})]])
|
||||
|
||||
(defn item-image
|
||||
[{:keys[source style image-style]}]
|
||||
[{:keys [source style image-style]}]
|
||||
[react/view {:style style}
|
||||
[react/image {:source source
|
||||
:style (merge styles/item-image image-style)}]])
|
||||
|
@ -168,10 +168,10 @@
|
|||
|
||||
(defn- wrap-per-section-render-fn [props]
|
||||
(update
|
||||
(if-let [f (:render-fn props)]
|
||||
(assoc (dissoc props :render-fn) :renderItem (wrap-render-fn f))
|
||||
props)
|
||||
:data wrap-data))
|
||||
(if-let [f (:render-fn props)]
|
||||
(assoc (dissoc props :render-fn) :renderItem (wrap-render-fn f))
|
||||
props)
|
||||
:data wrap-data))
|
||||
|
||||
(defn section-list
|
||||
"A wrapper for SectionList.
|
||||
|
@ -203,7 +203,6 @@
|
|||
label]
|
||||
item-icon-forward]]])
|
||||
|
||||
|
||||
(defn action-list [actions {:keys [container-style action-separator-style] :as styles}]
|
||||
[react/view (merge styles/action-list container-style)
|
||||
[flat-list
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
(defn qr-code [props]
|
||||
(reagent/create-element
|
||||
rn-dependencies/qr-code
|
||||
(clj->js (merge {:inverted true} props))))
|
||||
rn-dependencies/qr-code
|
||||
(clj->js (merge {:inverted true} props))))
|
||||
|
||||
(defn- footer [style value]
|
||||
[react/view styles/footer
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
[react/view {:style (merge (styles/input-container height) container)}
|
||||
[react/text-input
|
||||
(merge
|
||||
{:style (merge styles/input style)
|
||||
:placeholder-text-color colors/gray
|
||||
:auto-focus true
|
||||
:auto-capitalize :none}
|
||||
(dissoc props :style :height))]]
|
||||
{:style (merge styles/input style)
|
||||
:placeholder-text-color colors/gray
|
||||
:auto-focus true
|
||||
:auto-capitalize :none}
|
||||
(dissoc props :style :height))]]
|
||||
(when error
|
||||
[tooltip/tooltip error (styles/error label)])])
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
(defn animate-tooltip [bottom-value bottom-anim-value opacity-value]
|
||||
(fn []
|
||||
(animation/start
|
||||
(animation/parallel
|
||||
[(animation/timing opacity-value {:toValue 1
|
||||
:duration 500})
|
||||
(animation/timing bottom-anim-value {:toValue (- bottom-value 10)
|
||||
:easing (.bezier (animation/easing) 0.685, 0.000, 0.025, 1.185)
|
||||
:duration 500})]))))
|
||||
(animation/parallel
|
||||
[(animation/timing opacity-value {:toValue 1
|
||||
:duration 500})
|
||||
(animation/timing bottom-anim-value {:toValue (- bottom-value 10)
|
||||
:easing (.bezier (animation/easing) 0.685, 0.000, 0.025, 1.185)
|
||||
:duration 500})]))))
|
|
@ -32,13 +32,13 @@
|
|||
(spec/def :account/seed-backed-up? (spec/nilable boolean?))
|
||||
|
||||
(spec/def :accounts/account (allowed-keys
|
||||
:req-un [:account/name :account/address :account/public-key
|
||||
:account/photo-path :account/signing-phrase]
|
||||
:opt-un [:account/debug? :account/status :account/last-updated
|
||||
:account/email :account/signed-up? :account/network
|
||||
:account/networks :account/settings :account/wnode
|
||||
:account/last-sign-in :account/sharing-usage-data? :account/dev-mode?
|
||||
:account/seed-backed-up? :account/mnemonic]))
|
||||
:req-un [:account/name :account/address :account/public-key
|
||||
:account/photo-path :account/signing-phrase]
|
||||
:opt-un [:account/debug? :account/status :account/last-updated
|
||||
:account/email :account/signed-up? :account/network
|
||||
:account/networks :account/settings :account/wnode
|
||||
:account/last-sign-in :account/sharing-usage-data? :account/dev-mode?
|
||||
:account/seed-backed-up? :account/mnemonic]))
|
||||
|
||||
(spec/def :accounts/accounts (spec/nilable (spec/map-of :account/address :accounts/account)))
|
||||
|
||||
|
|
|
@ -22,31 +22,31 @@
|
|||
;;;; COFX
|
||||
|
||||
(re-frame/reg-cofx
|
||||
::get-signing-phrase
|
||||
(fn [coeffects _]
|
||||
(assoc coeffects :signing-phrase (signing-phrase/generate))))
|
||||
::get-signing-phrase
|
||||
(fn [coeffects _]
|
||||
(assoc coeffects :signing-phrase (signing-phrase/generate))))
|
||||
|
||||
(re-frame/reg-cofx
|
||||
::get-status
|
||||
(fn [coeffects _]
|
||||
(assoc coeffects :status (rand-nth statuses/data))))
|
||||
::get-status
|
||||
(fn [coeffects _]
|
||||
(assoc coeffects :status (rand-nth statuses/data))))
|
||||
|
||||
;;;; FX
|
||||
|
||||
(re-frame/reg-fx
|
||||
::create-account
|
||||
(fn [password]
|
||||
(status/create-account
|
||||
password
|
||||
#(re-frame/dispatch [::account-created (json->clj %) password]))))
|
||||
::create-account
|
||||
(fn [password]
|
||||
(status/create-account
|
||||
password
|
||||
#(re-frame/dispatch [::account-created (json->clj %) password]))))
|
||||
|
||||
;;;; Handlers
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:create-account
|
||||
(fn [{{:accounts/keys [create] :as db} :db} _]
|
||||
{:db (update db :accounts/create assoc :step :account-creating :error nil)
|
||||
::create-account (:password create)}))
|
||||
:create-account
|
||||
(fn [{{:accounts/keys [create] :as db} :db} _]
|
||||
{:db (update db :accounts/create assoc :step :account-creating :error nil)
|
||||
::create-account (:password create)}))
|
||||
|
||||
(defn add-account
|
||||
"Takes db and new account, creates map of effects describing adding account to database and realm"
|
||||
|
@ -60,51 +60,51 @@
|
|||
|
||||
;; TODO(janherich) we have this handler here only because of the tests, refactor/improve tests ASAP
|
||||
(handlers/register-handler-fx
|
||||
:add-account
|
||||
(fn [{:keys [db]} [_ new-account]]
|
||||
(add-account db new-account)))
|
||||
:add-account
|
||||
(fn [{:keys [db]} [_ new-account]]
|
||||
(add-account db new-account)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
::account-created
|
||||
[re-frame/trim-v (re-frame/inject-cofx ::get-signing-phrase) (re-frame/inject-cofx ::get-status)]
|
||||
(fn [{:keys [signing-phrase status db] :as cofx} [{:keys [pubkey address mnemonic]} password]]
|
||||
(let [normalized-address (utils.hex/normalize-hex address)
|
||||
account {:public-key pubkey
|
||||
:address normalized-address
|
||||
:name (generate-gfy pubkey)
|
||||
:status status
|
||||
:signed-up? true
|
||||
:photo-path (identicon pubkey)
|
||||
:signing-phrase signing-phrase
|
||||
:mnemonic mnemonic
|
||||
:settings constants/default-account-settings}]
|
||||
(log/debug "account-created")
|
||||
(when-not (str/blank? pubkey)
|
||||
(-> (add-account db account)
|
||||
(assoc :dispatch [:login-account normalized-address password]))))))
|
||||
::account-created
|
||||
[re-frame/trim-v (re-frame/inject-cofx ::get-signing-phrase) (re-frame/inject-cofx ::get-status)]
|
||||
(fn [{:keys [signing-phrase status db] :as cofx} [{:keys [pubkey address mnemonic]} password]]
|
||||
(let [normalized-address (utils.hex/normalize-hex address)
|
||||
account {:public-key pubkey
|
||||
:address normalized-address
|
||||
:name (generate-gfy pubkey)
|
||||
:status status
|
||||
:signed-up? true
|
||||
:photo-path (identicon pubkey)
|
||||
:signing-phrase signing-phrase
|
||||
:mnemonic mnemonic
|
||||
:settings constants/default-account-settings}]
|
||||
(log/debug "account-created")
|
||||
(when-not (str/blank? pubkey)
|
||||
(-> (add-account db account)
|
||||
(assoc :dispatch [:login-account normalized-address password]))))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:load-accounts
|
||||
[(re-frame/inject-cofx :data-store/get-all-accounts)]
|
||||
(fn [{:keys [db all-accounts]} _]
|
||||
(let [accounts (->> all-accounts
|
||||
(map (fn [{:keys [address] :as account}]
|
||||
[address account]))
|
||||
(into {}))
|
||||
:load-accounts
|
||||
[(re-frame/inject-cofx :data-store/get-all-accounts)]
|
||||
(fn [{:keys [db all-accounts]} _]
|
||||
(let [accounts (->> all-accounts
|
||||
(map (fn [{:keys [address] :as account}]
|
||||
[address account]))
|
||||
(into {}))
|
||||
;;workaround for realm bug, migrating account v4
|
||||
events (mapv #(when (empty? (:networks %)) [:account-update-networks (:address %)]) (vals accounts))]
|
||||
(merge
|
||||
{:db (assoc db :accounts/accounts accounts)}
|
||||
(when-not (empty? events)
|
||||
{:dispatch-n events})))))
|
||||
events (mapv #(when (empty? (:networks %)) [:account-update-networks (:address %)]) (vals accounts))]
|
||||
(merge
|
||||
{:db (assoc db :accounts/accounts accounts)}
|
||||
(when-not (empty? events)
|
||||
{:dispatch-n events})))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:account-update-networks
|
||||
(fn [{{:accounts/keys [accounts] :networks/keys [networks] :as db} :db} [_ id]]
|
||||
(let [current-account (get accounts id)
|
||||
new-account (assoc current-account :networks networks)]
|
||||
{:db (assoc-in db [:accounts/accounts id] new-account)
|
||||
:data-store/save-account new-account})))
|
||||
:account-update-networks
|
||||
(fn [{{:accounts/keys [accounts] :networks/keys [networks] :as db} :db} [_ id]]
|
||||
(let [current-account (get accounts id)
|
||||
new-account (assoc current-account :networks networks)]
|
||||
{:db (assoc-in db [:accounts/accounts id] new-account)
|
||||
:data-store/save-account new-account})))
|
||||
|
||||
(defn update-settings [settings {{:keys [account/account] :as db} :db :as cofx}]
|
||||
(let [new-account (assoc account :settings settings)]
|
||||
|
@ -112,47 +112,47 @@
|
|||
:data-store/save-account new-account}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:send-account-update-if-needed
|
||||
(fn [{:keys [db now] :as cofx} _]
|
||||
(let [{:keys [last-updated]} (:account/account db)
|
||||
needs-update? (> (- now last-updated) time/week)]
|
||||
(log/info "Need to send account-update: " needs-update?)
|
||||
(when needs-update?
|
||||
:send-account-update-if-needed
|
||||
(fn [{:keys [db now] :as cofx} _]
|
||||
(let [{:keys [last-updated]} (:account/account db)
|
||||
needs-update? (> (- now last-updated) time/week)]
|
||||
(log/info "Need to send account-update: " needs-update?)
|
||||
(when needs-update?
|
||||
;; TODO(janherich): this is very strange and misleading, need to figure out why it'd necessary to update
|
||||
;; account with network update when last update was more then week ago
|
||||
(accounts.utils/account-update nil cofx)))))
|
||||
(accounts.utils/account-update nil cofx)))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:account-set-name
|
||||
(fn [{{:accounts/keys [create] :as db} :db :as cofx} _]
|
||||
(handlers-macro/merge-fx cofx
|
||||
{:db db
|
||||
:dispatch [:navigate-to-clean :usage-data [:account-finalized]]}
|
||||
(accounts.utils/account-update {:name (:name create)}))))
|
||||
:account-set-name
|
||||
(fn [{{:accounts/keys [create] :as db} :db :as cofx} _]
|
||||
(handlers-macro/merge-fx cofx
|
||||
{:db db
|
||||
:dispatch [:navigate-to-clean :usage-data [:account-finalized]]}
|
||||
(accounts.utils/account-update {:name (:name create)}))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:account-finalized
|
||||
(fn [{db :db} _]
|
||||
{:db (assoc db :accounts/create {:show-welcome? true})
|
||||
:dispatch-n [[:navigate-to-clean :home]
|
||||
[:request-notifications]]}))
|
||||
:account-finalized
|
||||
(fn [{db :db} _]
|
||||
{:db (assoc db :accounts/create {:show-welcome? true})
|
||||
:dispatch-n [[:navigate-to-clean :home]
|
||||
[:request-notifications]]}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:account-set-input-text
|
||||
(fn [{db :db} [_ input-key text]]
|
||||
{:db (update db :accounts/create merge {input-key text :error nil})}))
|
||||
:account-set-input-text
|
||||
(fn [{db :db} [_ input-key text]]
|
||||
{:db (update db :accounts/create merge {input-key text :error nil})}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:update-sign-in-time
|
||||
(fn [{db :db now :now :as cofx} _]
|
||||
(accounts.utils/account-update {:last-sign-in now} cofx)))
|
||||
:update-sign-in-time
|
||||
(fn [{db :db now :now :as cofx} _]
|
||||
(accounts.utils/account-update {:last-sign-in now} cofx)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:reset-account-creation
|
||||
(fn [{db :db} _]
|
||||
{:db (update db :accounts/create assoc :step :enter-password :password nil :password-confirm nil :error nil)}))
|
||||
:reset-account-creation
|
||||
(fn [{db :db} _]
|
||||
{:db (update db :accounts/create assoc :step :enter-password :password nil :password-confirm nil :error nil)}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:switch-dev-mode
|
||||
(fn [cofx [_ dev-mode]]
|
||||
(accounts.utils/account-update {:dev-mode? dev-mode} cofx)))
|
||||
:switch-dev-mode
|
||||
(fn [cofx [_ dev-mode]]
|
||||
(accounts.utils/account-update {:dev-mode? dev-mode} cofx)))
|
||||
|
|
|
@ -16,53 +16,53 @@
|
|||
(reg-fx ::stop-node (fn [] (status/stop-node)))
|
||||
|
||||
(reg-fx
|
||||
::login
|
||||
(fn [[address password]]
|
||||
(status/login address password #(dispatch [:login-handler % address]))))
|
||||
::login
|
||||
(fn [[address password]]
|
||||
(status/login address password #(dispatch [:login-handler % address]))))
|
||||
|
||||
(reg-fx
|
||||
::clear-web-data
|
||||
(fn []
|
||||
(status/clear-web-data)))
|
||||
::clear-web-data
|
||||
(fn []
|
||||
(status/clear-web-data)))
|
||||
|
||||
(reg-fx
|
||||
::change-account
|
||||
(fn [[address]]
|
||||
::change-account
|
||||
(fn [[address]]
|
||||
;; if we don't add delay when running app without status-go
|
||||
;; "null is not an object (evaluating 'realm.schema')" error appears
|
||||
(keychain/get-encryption-key-then
|
||||
(fn [encryption-key]
|
||||
(let [change-account-fn (fn [] (data-store/change-account address
|
||||
false
|
||||
encryption-key
|
||||
#(dispatch [:change-account-handler % address])))]
|
||||
(if config/stub-status-go?
|
||||
(utils/set-timeout change-account-fn
|
||||
300)
|
||||
(change-account-fn)))))))
|
||||
(keychain/get-encryption-key-then
|
||||
(fn [encryption-key]
|
||||
(let [change-account-fn (fn [] (data-store/change-account address
|
||||
false
|
||||
encryption-key
|
||||
#(dispatch [:change-account-handler % address])))]
|
||||
(if config/stub-status-go?
|
||||
(utils/set-timeout change-account-fn
|
||||
300)
|
||||
(change-account-fn)))))))
|
||||
|
||||
;;;; Handlers
|
||||
|
||||
(register-handler-fx
|
||||
:open-login
|
||||
(fn [{db :db} [_ address photo-path name]]
|
||||
{:db (update db
|
||||
:accounts/login assoc
|
||||
:address address
|
||||
:photo-path photo-path
|
||||
:name name)
|
||||
:dispatch [:navigate-to :login]}))
|
||||
:open-login
|
||||
(fn [{db :db} [_ address photo-path name]]
|
||||
{:db (update db
|
||||
:accounts/login assoc
|
||||
:address address
|
||||
:photo-path photo-path
|
||||
:name name)
|
||||
:dispatch [:navigate-to :login]}))
|
||||
|
||||
(defn wrap-with-login-account-fx [db address password]
|
||||
{:db db
|
||||
::login [address password]})
|
||||
|
||||
(register-handler-fx
|
||||
::login-account
|
||||
(fn [{db :db} [_ address password]]
|
||||
(wrap-with-login-account-fx
|
||||
(assoc db :node/after-start nil)
|
||||
address password)))
|
||||
::login-account
|
||||
(fn [{db :db} [_ address password]]
|
||||
(wrap-with-login-account-fx
|
||||
(assoc db :node/after-start nil)
|
||||
address password)))
|
||||
|
||||
(defn get-network-by-address [db address]
|
||||
(let [accounts (get db :accounts/accounts)
|
||||
|
@ -78,55 +78,55 @@
|
|||
:node/after-start [::login-account address password])}))
|
||||
|
||||
(register-handler-fx
|
||||
::start-node
|
||||
(fn [{db :db} [_ address password]]
|
||||
(wrap-with-initialize-geth-fx
|
||||
(assoc db :node/after-stop nil)
|
||||
address password)))
|
||||
::start-node
|
||||
(fn [{db :db} [_ address password]]
|
||||
(wrap-with-initialize-geth-fx
|
||||
(assoc db :node/after-stop nil)
|
||||
address password)))
|
||||
|
||||
(defn wrap-with-stop-node-fx [db address password]
|
||||
{:db (assoc db :node/after-stop [::start-node address password])
|
||||
::stop-node nil})
|
||||
|
||||
(register-handler-fx
|
||||
:login-account
|
||||
(fn [{{:keys [network status-node-started?] :as db} :db} [_ address password]]
|
||||
(let [{account-network :network} (get-network-by-address db address)
|
||||
db' (-> db
|
||||
(assoc-in [:accounts/login :processing] true))
|
||||
wrap-fn (cond (not status-node-started?)
|
||||
wrap-with-initialize-geth-fx
|
||||
:login-account
|
||||
(fn [{{:keys [network status-node-started?] :as db} :db} [_ address password]]
|
||||
(let [{account-network :network} (get-network-by-address db address)
|
||||
db' (-> db
|
||||
(assoc-in [:accounts/login :processing] true))
|
||||
wrap-fn (cond (not status-node-started?)
|
||||
wrap-with-initialize-geth-fx
|
||||
|
||||
(= account-network network)
|
||||
wrap-with-login-account-fx
|
||||
(= account-network network)
|
||||
wrap-with-login-account-fx
|
||||
|
||||
:else
|
||||
wrap-with-stop-node-fx)]
|
||||
(wrap-fn db' address password))))
|
||||
:else
|
||||
wrap-with-stop-node-fx)]
|
||||
(wrap-fn db' address password))))
|
||||
|
||||
(register-handler-fx
|
||||
:login-handler
|
||||
(fn [{db :db} [_ login-result address]]
|
||||
(let [data (json->clj login-result)
|
||||
error (:error data)
|
||||
success (zero? (count error))
|
||||
db' (assoc-in db [:accounts/login :processing] false)]
|
||||
(if success
|
||||
{:db db'
|
||||
::clear-web-data nil
|
||||
::change-account [address]}
|
||||
{:db (assoc-in db' [:accounts/login :error] error)}))))
|
||||
:login-handler
|
||||
(fn [{db :db} [_ login-result address]]
|
||||
(let [data (json->clj login-result)
|
||||
error (:error data)
|
||||
success (zero? (count error))
|
||||
db' (assoc-in db [:accounts/login :processing] false)]
|
||||
(if success
|
||||
{:db db'
|
||||
::clear-web-data nil
|
||||
::change-account [address]}
|
||||
{:db (assoc-in db' [:accounts/login :error] error)}))))
|
||||
|
||||
(register-handler-fx
|
||||
:change-account-handler
|
||||
(fn [{{:keys [accounts/accounts view-id] :as db} :db} [_ error address]]
|
||||
(if (nil? error)
|
||||
{:db (cond-> (dissoc db :accounts/login)
|
||||
(= view-id :create-account)
|
||||
(assoc-in [:accounts/create :step] :enter-name))
|
||||
:dispatch-n (concat
|
||||
[[:stop-debugging]
|
||||
[:initialize-account address
|
||||
(when (not= view-id :create-account)
|
||||
[[:navigate-to-clean :home]])]])}
|
||||
(log/debug "Error changing acount: " error))))
|
||||
:change-account-handler
|
||||
(fn [{{:keys [accounts/accounts view-id] :as db} :db} [_ error address]]
|
||||
(if (nil? error)
|
||||
{:db (cond-> (dissoc db :accounts/login)
|
||||
(= view-id :create-account)
|
||||
(assoc-in [:accounts/create :step] :enter-name))
|
||||
:dispatch-n (concat
|
||||
[[:stop-debugging]
|
||||
[:initialize-account address
|
||||
(when (not= view-id :create-account)
|
||||
[[:navigate-to-clean :home]])]])}
|
||||
(log/debug "Error changing acount: " error))))
|
||||
|
|
|
@ -1,52 +1,52 @@
|
|||
(ns status-im.ui.screens.accounts.recover.events
|
||||
(:require
|
||||
status-im.ui.screens.accounts.recover.navigation
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.ui.screens.accounts.events :as accounts-events]
|
||||
[status-im.utils.types :as types]
|
||||
[status-im.utils.identicon :as identicon]
|
||||
[clojure.string :as string]
|
||||
[status-im.utils.handlers :as handlers]
|
||||
[status-im.utils.gfycat.core :as gfycat]
|
||||
[status-im.utils.signing-phrase.core :as signing-phrase]
|
||||
[status-im.utils.hex :as utils.hex]
|
||||
[status-im.constants :as constants]))
|
||||
status-im.ui.screens.accounts.recover.navigation
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.ui.screens.accounts.events :as accounts-events]
|
||||
[status-im.utils.types :as types]
|
||||
[status-im.utils.identicon :as identicon]
|
||||
[clojure.string :as string]
|
||||
[status-im.utils.handlers :as handlers]
|
||||
[status-im.utils.gfycat.core :as gfycat]
|
||||
[status-im.utils.signing-phrase.core :as signing-phrase]
|
||||
[status-im.utils.hex :as utils.hex]
|
||||
[status-im.constants :as constants]))
|
||||
|
||||
;;;; FX
|
||||
|
||||
(re-frame/reg-fx
|
||||
::recover-account-fx
|
||||
(fn [[passphrase password]]
|
||||
(status/recover-account
|
||||
(string/trim passphrase)
|
||||
password
|
||||
#(re-frame/dispatch [:account-recovered % password]))))
|
||||
::recover-account-fx
|
||||
(fn [[passphrase password]]
|
||||
(status/recover-account
|
||||
(string/trim passphrase)
|
||||
password
|
||||
#(re-frame/dispatch [:account-recovered % password]))))
|
||||
|
||||
;;;; Handlers
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:account-recovered
|
||||
(fn [{:keys [db]} [_ result password]]
|
||||
(let [data (types/json->clj result)
|
||||
public-key (:pubkey data)
|
||||
address (-> data :address utils.hex/normalize-hex)
|
||||
phrase (signing-phrase/generate)
|
||||
account {:public-key public-key
|
||||
:address address
|
||||
:name (gfycat/generate-gfy public-key)
|
||||
:photo-path (identicon/identicon public-key)
|
||||
:mnemonic ""
|
||||
:signed-up? true
|
||||
:signing-phrase phrase
|
||||
:settings constants/default-account-settings}]
|
||||
(when-not (string/blank? public-key)
|
||||
(-> db
|
||||
(accounts-events/add-account account)
|
||||
(assoc :dispatch [:login-account address password])
|
||||
(assoc :dispatch-later [{:ms 2000 :dispatch [:navigate-to :usage-data]}]))))))
|
||||
:account-recovered
|
||||
(fn [{:keys [db]} [_ result password]]
|
||||
(let [data (types/json->clj result)
|
||||
public-key (:pubkey data)
|
||||
address (-> data :address utils.hex/normalize-hex)
|
||||
phrase (signing-phrase/generate)
|
||||
account {:public-key public-key
|
||||
:address address
|
||||
:name (gfycat/generate-gfy public-key)
|
||||
:photo-path (identicon/identicon public-key)
|
||||
:mnemonic ""
|
||||
:signed-up? true
|
||||
:signing-phrase phrase
|
||||
:settings constants/default-account-settings}]
|
||||
(when-not (string/blank? public-key)
|
||||
(-> db
|
||||
(accounts-events/add-account account)
|
||||
(assoc :dispatch [:login-account address password])
|
||||
(assoc :dispatch-later [{:ms 2000 :dispatch [:navigate-to :usage-data]}]))))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:recover-account
|
||||
(fn [_ [_ passphrase password]]
|
||||
{::recover-account-fx [passphrase password]}))
|
||||
:recover-account
|
||||
(fn [_ [_ passphrase password]]
|
||||
{::recover-account-fx [passphrase password]}))
|
||||
|
|
|
@ -48,8 +48,8 @@
|
|||
(defview recover []
|
||||
(letsubs [{:keys [passphrase password]} [:get :accounts/recover]]
|
||||
(let [valid-form? (and
|
||||
(spec/valid? ::recover.db/passphrase passphrase)
|
||||
(spec/valid? ::db/password password))]
|
||||
(spec/valid? ::recover.db/passphrase passphrase)
|
||||
(spec/valid? ::db/password password))]
|
||||
[react/keyboard-avoiding-view {:style styles/screen-container}
|
||||
[status-bar/status-bar]
|
||||
[toolbar/toolbar nil toolbar/default-nav-back
|
||||
|
|
|
@ -6,25 +6,25 @@
|
|||
[cljs.spec.alpha :as spec]))
|
||||
|
||||
(reg-sub :get-current-public-key
|
||||
(fn [db]
|
||||
(:current-public-key db)))
|
||||
(fn [db]
|
||||
(:current-public-key db)))
|
||||
|
||||
(reg-sub :get-accounts
|
||||
(fn [db]
|
||||
(:accounts/accounts db)))
|
||||
(fn [db]
|
||||
(:accounts/accounts db)))
|
||||
|
||||
(reg-sub :get-current-account
|
||||
(fn [db]
|
||||
(:account/account db)))
|
||||
(fn [db]
|
||||
(:account/account db)))
|
||||
|
||||
(reg-sub :get-current-account-hex
|
||||
:<- [:get-current-account]
|
||||
(fn [{:keys [address]}]
|
||||
(ethereum/normalized-address address)))
|
||||
:<- [:get-current-account]
|
||||
(fn [{:keys [address]}]
|
||||
(ethereum/normalized-address address)))
|
||||
|
||||
(reg-sub
|
||||
:get-account-creation-next-enabled?
|
||||
(fn [{:accounts/keys [create]}]
|
||||
:get-account-creation-next-enabled?
|
||||
(fn [{:accounts/keys [create]}]
|
||||
(let [{:keys [step password password-confirm name]} create]
|
||||
(or (and password (= :enter-password step) (spec/valid? ::db/password password))
|
||||
(and password-confirm (= :confirm-password step) (spec/valid? ::db/password password-confirm))
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
[status-im.utils.handlers-macro :as handlers-macro]
|
||||
[status-im.transport.message.v1.contact :as message.contact]))
|
||||
|
||||
|
||||
(defn account-update
|
||||
"Takes effects (containing :db) + new account fields, adds all effects necessary for account update.
|
||||
Optionally, one can specify event to be dispatched after fields are persisted."
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
(when (and whisper-identity (not (string/blank? whisper-identity)))
|
||||
(cond
|
||||
(#{(hex/normalize-hex address) (hex/normalize-hex public-key)}
|
||||
(hex/normalize-hex whisper-identity))
|
||||
(hex/normalize-hex whisper-identity))
|
||||
(i18n/label :t/can-not-add-yourself)
|
||||
|
||||
(not (spec/valid? :global/public-key whisper-identity))
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
[status-im.ui.screens.add-new.new-chat.db :as db]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:new-contact-error-message
|
||||
:<- [:get :contacts/new-identity]
|
||||
:<- [:get-current-account]
|
||||
(fn [[new-identity account]]
|
||||
:new-contact-error-message
|
||||
:<- [:get :contacts/new-identity]
|
||||
:<- [:get-current-account]
|
||||
(fn [[new-identity account]]
|
||||
(db/validate-pub-key new-identity account)))
|
|
@ -15,18 +15,18 @@
|
|||
|
||||
(spec/def :browser/options
|
||||
(allowed-keys
|
||||
:opt-un [:browser/browser-id
|
||||
:browser/can-go-back?
|
||||
:browser/can-go-forward?
|
||||
:browser/fullscreen?]))
|
||||
:opt-un [:browser/browser-id
|
||||
:browser/can-go-back?
|
||||
:browser/can-go-forward?
|
||||
:browser/fullscreen?]))
|
||||
|
||||
(spec/def :browser/browser
|
||||
(allowed-keys
|
||||
:req-un [:browser/browser-id
|
||||
:browser/timestamp]
|
||||
:opt-un [:browser/name
|
||||
:browser/dapp?
|
||||
:browser/url
|
||||
:browser/contact]))
|
||||
:req-un [:browser/browser-id
|
||||
:browser/timestamp]
|
||||
:opt-un [:browser/name
|
||||
:browser/dapp?
|
||||
:browser/url
|
||||
:browser/contact]))
|
||||
|
||||
(spec/def :browser/browsers (spec/nilable (spec/map-of :global/not-empty-string :browser/browser)))
|
|
@ -6,25 +6,25 @@
|
|||
[status-im.i18n :as i18n]))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:initialize-browsers
|
||||
[(re-frame/inject-cofx :data-store/all-browsers)]
|
||||
(fn [{:keys [db all-stored-browsers]} _]
|
||||
(let [browsers (into {} (map #(vector (:browser-id %) %) all-stored-browsers))]
|
||||
{:db (assoc db :browser/browsers browsers)})))
|
||||
:initialize-browsers
|
||||
[(re-frame/inject-cofx :data-store/all-browsers)]
|
||||
(fn [{:keys [db all-stored-browsers]} _]
|
||||
(let [browsers (into {} (map #(vector (:browser-id %) %) all-stored-browsers))]
|
||||
{:db (assoc db :browser/browsers browsers)})))
|
||||
|
||||
(defn match-url [url]
|
||||
(str (when (and url (not (re-find #"^[a-zA-Z-_]+:/" url))) "http://") url))
|
||||
|
||||
(defn get-new-browser [browser now]
|
||||
(cond-> browser
|
||||
true
|
||||
(assoc :timestamp now)
|
||||
(not (:browser-id browser))
|
||||
(assoc :browser-id (random/id))
|
||||
(not (:name browser))
|
||||
(assoc :name (i18n/label :t/browser))
|
||||
(:url browser)
|
||||
(update :url match-url)))
|
||||
true
|
||||
(assoc :timestamp now)
|
||||
(not (:browser-id browser))
|
||||
(assoc :browser-id (random/id))
|
||||
(not (:name browser))
|
||||
(assoc :name (i18n/label :t/browser))
|
||||
(:url browser)
|
||||
(update :url match-url)))
|
||||
|
||||
(defn add-browser-fx [{:keys [db now] :as cofx} browser]
|
||||
(let [new-browser (get-new-browser browser now)]
|
||||
|
@ -32,42 +32,42 @@
|
|||
:data-store/save-browser new-browser}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:open-dapp-in-browser
|
||||
[re-frame/trim-v]
|
||||
(fn [cofx [{:keys [name dapp-url] :as contact}]]
|
||||
(let [browser {:browser-id (:whisper-identity contact)
|
||||
:name name
|
||||
:dapp? true
|
||||
:url dapp-url
|
||||
:contact (:whisper-identity contact)}]
|
||||
(merge (add-browser-fx cofx browser)
|
||||
{:dispatch [:navigate-to :browser {:browser/browser-id (:browser-id browser)}]}))))
|
||||
:open-dapp-in-browser
|
||||
[re-frame/trim-v]
|
||||
(fn [cofx [{:keys [name dapp-url] :as contact}]]
|
||||
(let [browser {:browser-id (:whisper-identity contact)
|
||||
:name name
|
||||
:dapp? true
|
||||
:url dapp-url
|
||||
:contact (:whisper-identity contact)}]
|
||||
(merge (add-browser-fx cofx browser)
|
||||
{:dispatch [:navigate-to :browser {:browser/browser-id (:browser-id browser)}]}))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:open-browser
|
||||
[re-frame/trim-v]
|
||||
(fn [{:keys [now] :as cofx} [browser]]
|
||||
(let [new-browser (get-new-browser browser now)]
|
||||
(merge (add-browser-fx cofx new-browser)
|
||||
{:dispatch [:navigate-to :browser {:browser/browser-id (:browser-id new-browser)}]}))))
|
||||
:open-browser
|
||||
[re-frame/trim-v]
|
||||
(fn [{:keys [now] :as cofx} [browser]]
|
||||
(let [new-browser (get-new-browser browser now)]
|
||||
(merge (add-browser-fx cofx new-browser)
|
||||
{:dispatch [:navigate-to :browser {:browser/browser-id (:browser-id new-browser)}]}))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:update-browser
|
||||
[re-frame/trim-v]
|
||||
(fn [{:keys [db now] :as cofx} [browser]]
|
||||
(let [new-browser (get-new-browser browser now)]
|
||||
(-> (add-browser-fx cofx new-browser)
|
||||
(update-in [:db :browser/options] #(assoc % :browser-id (:browser-id new-browser)))))))
|
||||
:update-browser
|
||||
[re-frame/trim-v]
|
||||
(fn [{:keys [db now] :as cofx} [browser]]
|
||||
(let [new-browser (get-new-browser browser now)]
|
||||
(-> (add-browser-fx cofx new-browser)
|
||||
(update-in [:db :browser/options] #(assoc % :browser-id (:browser-id new-browser)))))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:update-browser-options
|
||||
[re-frame/trim-v]
|
||||
(fn [{:keys [db now] :as cofx} [options]]
|
||||
{:db (update db :browser/options merge options)}))
|
||||
:update-browser-options
|
||||
[re-frame/trim-v]
|
||||
(fn [{:keys [db now] :as cofx} [options]]
|
||||
{:db (update db :browser/options merge options)}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:remove-browser
|
||||
[re-frame/trim-v]
|
||||
(fn [{:keys [db]} [browser-id]]
|
||||
{:db (update-in db [:browser/browsers] dissoc browser-id)
|
||||
:data-store/remove-browser browser-id}))
|
||||
:remove-browser
|
||||
[re-frame/trim-v]
|
||||
(fn [{:keys [db]} [browser-id]]
|
||||
{:db (update-in db [:browser/browsers] dissoc browser-id)
|
||||
:data-store/remove-browser browser-id}))
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
(re-frame/reg-sub :browsers :browser/browsers)
|
||||
|
||||
(re-frame/reg-sub
|
||||
:get-current-browser
|
||||
:<- [:get :browser/options]
|
||||
:<- [:browsers]
|
||||
(fn [[options browsers]]
|
||||
(get browsers (:browser-id options))))
|
||||
:get-current-browser
|
||||
:<- [:get :browser/options]
|
||||
:<- [:browsers]
|
||||
(fn [[options browsers]]
|
||||
(get browsers (:browser-id options))))
|
|
@ -51,13 +51,13 @@
|
|||
|
||||
(defn web-view-error []
|
||||
(reagent/as-element
|
||||
[react/view styles/web-view-error
|
||||
[react/text (i18n/label :t/web-view-error)]]))
|
||||
[react/view styles/web-view-error
|
||||
[react/text (i18n/label :t/web-view-error)]]))
|
||||
|
||||
(defn web-view-loading []
|
||||
(reagent/as-element
|
||||
[react/view styles/web-view-loading
|
||||
[components/activity-indicator {:animating true}]]))
|
||||
[react/view styles/web-view-loading
|
||||
[components/activity-indicator {:animating true}]]))
|
||||
|
||||
(defn on-navigation-change [event browser]
|
||||
(let [{:strs [url title canGoBack canGoForward]} (js->clj event)]
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
:on-press #(when click-handler
|
||||
(click-handler row action params))}]))
|
||||
|
||||
|
||||
(defview contact-list-modal []
|
||||
(letsubs [contacts [:all-added-people-contacts]
|
||||
click-handler [:get :contacts/click-handler]
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
:chat-id public-key
|
||||
:contact-info (prn-str contact-props)}]
|
||||
(handlers-macro/merge-fx cofx
|
||||
{:db (update-in db [:contacts/contacts public-key] merge contact-props)
|
||||
:data-store/save-contact contact-props}
|
||||
(chat.models/upsert-chat chat-props)))))
|
||||
{:db (update-in db [:contacts/contacts public-key] merge contact-props)
|
||||
:data-store/save-contact contact-props}
|
||||
(chat.models/upsert-chat chat-props)))))
|
||||
|
||||
(defn receive-contact-request-confirmation
|
||||
[public-key {:keys [name profile-image address fcm-token]}
|
||||
|
@ -38,10 +38,9 @@
|
|||
chat-props {:name name
|
||||
:chat-id public-key}]
|
||||
(handlers-macro/merge-fx cofx
|
||||
{:db (update-in db [:contacts/contacts public-key] merge contact-props)
|
||||
:data-store/save-contact contact-props}
|
||||
(chat.models/upsert-chat chat-props)))))
|
||||
|
||||
{:db (update-in db [:contacts/contacts public-key] merge contact-props)
|
||||
:data-store/save-contact contact-props}
|
||||
(chat.models/upsert-chat chat-props)))))
|
||||
|
||||
(defn- update-contact [{:keys [whisper-identity] :as contact} {:keys [db]}]
|
||||
(when (get-in db [:contacts/contacts whisper-identity])
|
||||
|
@ -59,7 +58,7 @@
|
|||
:last-updated now}]
|
||||
(if (chats public-key)
|
||||
(handlers-macro/merge-fx cofx
|
||||
(update-contact contact)
|
||||
(chat.models/upsert-chat {:chat-id chat-id
|
||||
:name name}))
|
||||
(update-contact contact)
|
||||
(chat.models/upsert-chat {:chat-id chat-id
|
||||
:name name}))
|
||||
(update-contact contact cofx))))))))
|
||||
|
|
|
@ -38,29 +38,29 @@
|
|||
|
||||
(spec/def :contact/contact
|
||||
(allowed-keys
|
||||
:req-un [:contact/name]
|
||||
:opt-un [:contact/whisper-identity
|
||||
:contact/address
|
||||
:contact/public-key
|
||||
:contact/photo-path
|
||||
:contact/status
|
||||
:contact/last-updated
|
||||
:contact/last-online
|
||||
:contact/pending?
|
||||
:contact/hide-contact?
|
||||
:contact/unremovable?
|
||||
:contact/dapp?
|
||||
:contact/dapp-url
|
||||
:contact/dapp-hash
|
||||
:contact/bot-url
|
||||
:contact/jail-loaded?
|
||||
:contact/jail-loaded-events
|
||||
:contact/command
|
||||
:contact/response
|
||||
:contact/debug?
|
||||
:contact/subscriptions
|
||||
:contact/fcm-token
|
||||
:contact/description]))
|
||||
:req-un [:contact/name]
|
||||
:opt-un [:contact/whisper-identity
|
||||
:contact/address
|
||||
:contact/public-key
|
||||
:contact/photo-path
|
||||
:contact/status
|
||||
:contact/last-updated
|
||||
:contact/last-online
|
||||
:contact/pending?
|
||||
:contact/hide-contact?
|
||||
:contact/unremovable?
|
||||
:contact/dapp?
|
||||
:contact/dapp-url
|
||||
:contact/dapp-hash
|
||||
:contact/bot-url
|
||||
:contact/jail-loaded?
|
||||
:contact/jail-loaded-events
|
||||
:contact/command
|
||||
:contact/response
|
||||
:contact/debug?
|
||||
:contact/subscriptions
|
||||
:contact/fcm-token
|
||||
:contact/description]))
|
||||
|
||||
;;Contact list ui props
|
||||
(spec/def :contact-list-ui/edit? boolean?)
|
||||
|
@ -68,7 +68,6 @@
|
|||
;;Contacts ui props
|
||||
(spec/def :contacts-ui/edit? boolean?)
|
||||
|
||||
|
||||
(spec/def :contacts/contacts (spec/nilable (spec/map-of :global/not-empty-string :contact/contact)))
|
||||
;public key of new contact during adding this new contact
|
||||
(spec/def :contacts/new-identity (spec/nilable string?))
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
[re-frame.core :as re-frame]
|
||||
[status-im.utils.handlers :as handlers]
|
||||
[status-im.utils.handlers-macro :as handlers-macro]
|
||||
[status-im.utils.contacts :as utils.contacts]
|
||||
[status-im.utils.contacts :as utils.contacts]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.utils.identicon :as identicon]
|
||||
[status-im.utils.gfycat.core :as gfycat.core]
|
||||
|
@ -13,7 +13,7 @@
|
|||
[status-im.ui.screens.group.events :as group.events]
|
||||
[status-im.chat.console :as console-chat]
|
||||
[status-im.chat.events :as chat.events]
|
||||
[status-im.chat.models :as chat.models]
|
||||
[status-im.chat.models :as chat.models]
|
||||
[status-im.transport.message.core :as transport]
|
||||
[status-im.transport.message.v1.contact :as message.v1.contact]
|
||||
[status-im.ui.screens.add-new.new-chat.db :as new-chat.db]))
|
||||
|
@ -26,12 +26,12 @@
|
|||
:data-store/save-contact contact}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:load-contacts
|
||||
[(re-frame/inject-cofx :data-store/get-all-contacts)]
|
||||
(fn [{:keys [db all-contacts]} _]
|
||||
(let [contacts-list (map #(vector (:whisper-identity %) %) all-contacts)
|
||||
contacts (into {} contacts-list)]
|
||||
{:db (update db :contacts/contacts #(merge contacts %))})))
|
||||
:load-contacts
|
||||
[(re-frame/inject-cofx :data-store/get-all-contacts)]
|
||||
(fn [{:keys [db all-contacts]} _]
|
||||
(let [contacts-list (map #(vector (:whisper-identity %) %) all-contacts)
|
||||
contacts (into {} contacts-list)]
|
||||
{:db (update db :contacts/contacts #(merge contacts %))})))
|
||||
|
||||
(defn- add-new-contact [{:keys [whisper-identity] :as contact} {:keys [db]}]
|
||||
(let [new-contact (assoc contact :pending? false)]
|
||||
|
@ -64,69 +64,69 @@
|
|||
(defn add-contact [whisper-id {:keys [db] :as cofx}]
|
||||
(let [contact (build-contact whisper-id cofx)]
|
||||
(handlers-macro/merge-fx cofx
|
||||
(add-new-contact contact)
|
||||
(send-contact-request contact))))
|
||||
(add-new-contact contact)
|
||||
(send-contact-request contact))))
|
||||
|
||||
(defn add-contact-and-open-chat [whisper-id cofx]
|
||||
(handlers-macro/merge-fx cofx
|
||||
(navigation/navigate-to-clean :home)
|
||||
(add-contact whisper-id)
|
||||
(chat.events/start-chat whisper-id {})))
|
||||
(navigation/navigate-to-clean :home)
|
||||
(add-contact whisper-id)
|
||||
(chat.events/start-chat whisper-id {})))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:add-contact
|
||||
[(re-frame/inject-cofx :random-id)]
|
||||
(fn [cofx [_ whisper-id]]
|
||||
(add-contact whisper-id cofx)))
|
||||
:add-contact
|
||||
[(re-frame/inject-cofx :random-id)]
|
||||
(fn [cofx [_ whisper-id]]
|
||||
(add-contact whisper-id cofx)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:set-contact-identity-from-qr
|
||||
[(re-frame/inject-cofx :random-id)]
|
||||
(fn [{:keys [db] :as cofx} [_ _ contact-identity]]
|
||||
(let [current-account (:account/account db)
|
||||
fx {:db (assoc db :contacts/new-identity contact-identity)}]
|
||||
(if (new-chat.db/validate-pub-key contact-identity current-account)
|
||||
fx
|
||||
(handlers-macro/merge-fx cofx
|
||||
fx
|
||||
(add-contact-and-open-chat contact-identity))))))
|
||||
:set-contact-identity-from-qr
|
||||
[(re-frame/inject-cofx :random-id)]
|
||||
(fn [{:keys [db] :as cofx} [_ _ contact-identity]]
|
||||
(let [current-account (:account/account db)
|
||||
fx {:db (assoc db :contacts/new-identity contact-identity)}]
|
||||
(if (new-chat.db/validate-pub-key contact-identity current-account)
|
||||
fx
|
||||
(handlers-macro/merge-fx cofx
|
||||
fx
|
||||
(add-contact-and-open-chat contact-identity))))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:hide-contact
|
||||
(fn [cofx [_ {:keys [whisper-identity] :as contact}]]
|
||||
(update-contact {:whisper-identity whisper-identity
|
||||
:pending? true}
|
||||
cofx)))
|
||||
:hide-contact
|
||||
(fn [cofx [_ {:keys [whisper-identity] :as contact}]]
|
||||
(update-contact {:whisper-identity whisper-identity
|
||||
:pending? true}
|
||||
cofx)))
|
||||
|
||||
;;used only by status-dev-cli
|
||||
(handlers/register-handler-fx
|
||||
:remove-contact
|
||||
(fn [{:keys [db]} [_ whisper-identity]]
|
||||
(when-let [contact (get-in db [:contacts/contacts whisper-identity])]
|
||||
{:db (update db :contacts/contacts dissoc whisper-identity)
|
||||
:data-store/delete-contact contact})))
|
||||
:remove-contact
|
||||
(fn [{:keys [db]} [_ whisper-identity]]
|
||||
(when-let [contact (get-in db [:contacts/contacts whisper-identity])]
|
||||
{:db (update db :contacts/contacts dissoc whisper-identity)
|
||||
:data-store/delete-contact contact})))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:open-contact-toggle-list
|
||||
(fn [db [_ group-type]]
|
||||
(-> (assoc db
|
||||
:group/group-type group-type
|
||||
:group/selected-contacts #{}
|
||||
:new-chat-name "")
|
||||
(navigation/navigate-to :contact-toggle-list))))
|
||||
:open-contact-toggle-list
|
||||
(fn [db [_ group-type]]
|
||||
(-> (assoc db
|
||||
:group/group-type group-type
|
||||
:group/selected-contacts #{}
|
||||
:new-chat-name "")
|
||||
(navigation/navigate-to :contact-toggle-list))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:open-chat-with-contact
|
||||
[(re-frame/inject-cofx :random-id)]
|
||||
(fn [{:keys [db] :as cofx} [_ {:keys [whisper-identity] :as contact}]]
|
||||
(handlers-macro/merge-fx cofx
|
||||
(navigation/navigate-to-clean :home)
|
||||
(add-contact whisper-identity)
|
||||
(chat.events/start-chat whisper-identity {}))))
|
||||
:open-chat-with-contact
|
||||
[(re-frame/inject-cofx :random-id)]
|
||||
(fn [{:keys [db] :as cofx} [_ {:keys [whisper-identity] :as contact}]]
|
||||
(handlers-macro/merge-fx cofx
|
||||
(navigation/navigate-to-clean :home)
|
||||
(add-contact whisper-identity)
|
||||
(chat.events/start-chat whisper-identity {}))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:add-contact-handler
|
||||
[(re-frame/inject-cofx :random-id)]
|
||||
(fn [{{:contacts/keys [new-identity] :as db} :db :as cofx} _]
|
||||
(when (seq new-identity)
|
||||
(add-contact-and-open-chat new-identity cofx))))
|
||||
:add-contact-handler
|
||||
[(re-frame/inject-cofx :random-id)]
|
||||
(fn [{{:contacts/keys [new-identity] :as db} :db :as cofx} _]
|
||||
(when (seq new-identity)
|
||||
(add-contact-and-open-chat new-identity cofx))))
|
||||
|
|
|
@ -11,5 +11,5 @@
|
|||
(defmethod nav/preload-data! :contact-list-modal
|
||||
[db [_ _ {:keys [handler action params]}]]
|
||||
(assoc db :contacts/click-handler handler
|
||||
:contacts/click-action action
|
||||
:contacts/click-params params))
|
||||
:contacts/click-action action
|
||||
:contacts/click-params params))
|
|
@ -60,7 +60,7 @@
|
|||
|
||||
(def group-icon
|
||||
(assoc option-inner-image
|
||||
:tint-color common/color-gray))
|
||||
:tint-color common/color-gray))
|
||||
|
||||
; New contact
|
||||
|
||||
|
|
|
@ -10,16 +10,16 @@
|
|||
(reg-sub :get-contacts :contacts/contacts)
|
||||
|
||||
(reg-sub :get-current-contact
|
||||
:<- [:get-contacts]
|
||||
:<- [:get-current-contact-identity]
|
||||
(fn [[contacts identity]]
|
||||
(contacts identity)))
|
||||
:<- [:get-contacts]
|
||||
:<- [:get-current-contact-identity]
|
||||
(fn [[contacts identity]]
|
||||
(contacts identity)))
|
||||
|
||||
(reg-sub :get-current-chat-contact
|
||||
:<- [:get-contacts]
|
||||
:<- [:get-current-chat-id]
|
||||
(fn [[contacts chat-id]]
|
||||
(get contacts chat-id)))
|
||||
:<- [:get-contacts]
|
||||
:<- [:get-current-chat-id]
|
||||
(fn [[contacts chat-id]]
|
||||
(get contacts chat-id)))
|
||||
|
||||
(defn sort-contacts [contacts]
|
||||
(sort (fn [c1 c2]
|
||||
|
@ -30,67 +30,67 @@
|
|||
(vals contacts)))
|
||||
|
||||
(reg-sub :all-added-contacts
|
||||
:<- [:get-contacts]
|
||||
(fn [contacts]
|
||||
(->> contacts
|
||||
(remove (fn [[_ {:keys [pending? hide-contact?]}]]
|
||||
(or pending? hide-contact?)))
|
||||
(sort-contacts))))
|
||||
:<- [:get-contacts]
|
||||
(fn [contacts]
|
||||
(->> contacts
|
||||
(remove (fn [[_ {:keys [pending? hide-contact?]}]]
|
||||
(or pending? hide-contact?)))
|
||||
(sort-contacts))))
|
||||
|
||||
(reg-sub :all-added-people-contacts
|
||||
:<- [:all-added-contacts]
|
||||
(fn [contacts]
|
||||
(remove :dapp? contacts)))
|
||||
:<- [:all-added-contacts]
|
||||
(fn [contacts]
|
||||
(remove :dapp? contacts)))
|
||||
|
||||
(reg-sub :all-dapp-with-url-contacts
|
||||
:<- [:all-added-contacts]
|
||||
:<- [:get-current-account]
|
||||
(fn [[contacts {:keys [dev-mode?]}]]
|
||||
(filter #(and (:dapp? %) (:dapp-url %) (or dev-mode?
|
||||
(not= "simple-dapp" (:whisper-identity %))))
|
||||
contacts)))
|
||||
:<- [:all-added-contacts]
|
||||
:<- [:get-current-account]
|
||||
(fn [[contacts {:keys [dev-mode?]}]]
|
||||
(filter #(and (:dapp? %) (:dapp-url %) (or dev-mode?
|
||||
(not= "simple-dapp" (:whisper-identity %))))
|
||||
contacts)))
|
||||
|
||||
(reg-sub :get-people-in-current-chat
|
||||
:<- [:get-current-chat-contacts]
|
||||
(fn [contacts]
|
||||
(remove #(true? (:dapp? %)) contacts)))
|
||||
:<- [:get-current-chat-contacts]
|
||||
(fn [contacts]
|
||||
(remove #(true? (:dapp? %)) contacts)))
|
||||
|
||||
(defn filter-group-contacts [group-contacts contacts]
|
||||
(let [group-contacts' (into #{} group-contacts)]
|
||||
(filter #(group-contacts' (:whisper-identity %)) contacts)))
|
||||
|
||||
(reg-sub :get-all-added-group-contacts
|
||||
:<- [:all-added-contacts]
|
||||
:<- [:get-contact-groups]
|
||||
(fn [[contacts contact-groups] [_ group-id]]
|
||||
(filter-group-contacts (get-in contact-groups [group-id :contacts]) contacts)))
|
||||
:<- [:all-added-contacts]
|
||||
:<- [:get-contact-groups]
|
||||
(fn [[contacts contact-groups] [_ group-id]]
|
||||
(filter-group-contacts (get-in contact-groups [group-id :contacts]) contacts)))
|
||||
|
||||
(reg-sub :get-contact-by-identity
|
||||
:<- [:get-contacts]
|
||||
(fn [contacts [_ identity]]
|
||||
(get contacts identity)))
|
||||
:<- [:get-contacts]
|
||||
(fn [contacts [_ identity]]
|
||||
(get contacts identity)))
|
||||
|
||||
(reg-sub :get-contact-name-by-identity
|
||||
:<- [:get-contacts]
|
||||
:<- [:get-current-account]
|
||||
(fn [[contacts current-account] [_ identity]]
|
||||
(let [me? (= (:public-key current-account) identity)]
|
||||
(if me?
|
||||
(:name current-account)
|
||||
(:name (contacts identity))))))
|
||||
:<- [:get-contacts]
|
||||
:<- [:get-current-account]
|
||||
(fn [[contacts current-account] [_ identity]]
|
||||
(let [me? (= (:public-key current-account) identity)]
|
||||
(if me?
|
||||
(:name current-account)
|
||||
(:name (contacts identity))))))
|
||||
|
||||
(defn query-chat-contacts [[{:keys [contacts group-admin]} all-contacts] [_ query-fn]]
|
||||
(defn query-chat-contacts [[{:keys [contacts group-admin]} all-contacts] [_ query-fn]]
|
||||
(let [participant-set (into #{} (filter identity) (conj contacts group-admin))]
|
||||
(query-fn (comp participant-set :whisper-identity) (vals all-contacts))))
|
||||
|
||||
(reg-sub :query-current-chat-contacts
|
||||
:<- [:get-current-chat]
|
||||
:<- [:get-contacts]
|
||||
query-chat-contacts)
|
||||
:<- [:get-current-chat]
|
||||
:<- [:get-contacts]
|
||||
query-chat-contacts)
|
||||
|
||||
(reg-sub :get-all-contacts-not-in-current-chat
|
||||
:<- [:query-current-chat-contacts remove]
|
||||
identity)
|
||||
:<- [:query-current-chat-contacts remove]
|
||||
identity)
|
||||
|
||||
(defn get-all-contacts-in-group-chat [chat-contact-ids group-admin-id contacts current-account]
|
||||
(let [participant-set (into #{} (filter identity) (conj chat-contact-ids group-admin-id))
|
||||
|
@ -103,33 +103,33 @@
|
|||
participant-set)))
|
||||
|
||||
(reg-sub :get-current-chat-contacts
|
||||
:<- [:get-current-chat]
|
||||
:<- [:get-contacts]
|
||||
:<- [:get-current-account]
|
||||
(fn [[{:keys [contacts group-admin]} all-contacts current-account]]
|
||||
(get-all-contacts-in-group-chat contacts group-admin all-contacts current-account)))
|
||||
:<- [:get-current-chat]
|
||||
:<- [:get-contacts]
|
||||
:<- [:get-current-account]
|
||||
(fn [[{:keys [contacts group-admin]} all-contacts current-account]]
|
||||
(get-all-contacts-in-group-chat contacts group-admin all-contacts current-account)))
|
||||
|
||||
(reg-sub :get-contacts-by-chat
|
||||
(fn [[_ _ chat-id] _]
|
||||
[(subscribe [:get-chat chat-id])
|
||||
(subscribe [:get-contacts])])
|
||||
query-chat-contacts)
|
||||
(fn [[_ _ chat-id] _]
|
||||
[(subscribe [:get-chat chat-id])
|
||||
(subscribe [:get-contacts])])
|
||||
query-chat-contacts)
|
||||
|
||||
(reg-sub :get-chat-photo
|
||||
(fn [[_ chat-id] _]
|
||||
[(subscribe [:get-chat chat-id])
|
||||
(subscribe [:get-contacts-by-chat filter chat-id])])
|
||||
(fn [[chat contacts] [_ chat-id]]
|
||||
(when (and chat (not (:group-chat chat)))
|
||||
(cond
|
||||
(:photo-path chat)
|
||||
(:photo-path chat)
|
||||
(fn [[_ chat-id] _]
|
||||
[(subscribe [:get-chat chat-id])
|
||||
(subscribe [:get-contacts-by-chat filter chat-id])])
|
||||
(fn [[chat contacts] [_ chat-id]]
|
||||
(when (and chat (not (:group-chat chat)))
|
||||
(cond
|
||||
(:photo-path chat)
|
||||
(:photo-path chat)
|
||||
|
||||
(pos? (count contacts))
|
||||
(:photo-path (first contacts))
|
||||
(pos? (count contacts))
|
||||
(:photo-path (first contacts))
|
||||
|
||||
:else
|
||||
(identicon/identicon chat-id)))))
|
||||
:else
|
||||
(identicon/identicon chat-id)))))
|
||||
|
||||
(defn- address= [{:keys [address] :as contact} s]
|
||||
(when (and address (= (ethereum/normalized-address s)
|
||||
|
@ -141,16 +141,16 @@
|
|||
contact))
|
||||
|
||||
(reg-sub :get-contact-by-address
|
||||
:<- [:get-contacts]
|
||||
(fn [contacts [_ address]]
|
||||
(some #(contact-by-address % address) contacts)))
|
||||
:<- [:get-contacts]
|
||||
(fn [contacts [_ address]]
|
||||
(some #(contact-by-address % address) contacts)))
|
||||
|
||||
(reg-sub :get-contacts-by-address
|
||||
:<- [:get-contacts]
|
||||
(fn [contacts]
|
||||
(reduce (fn [acc [_ {:keys [address] :as contact}]]
|
||||
(if address
|
||||
(assoc acc address contact)
|
||||
acc))
|
||||
{}
|
||||
contacts)))
|
||||
:<- [:get-contacts]
|
||||
(fn [contacts]
|
||||
(reduce (fn [acc [_ {:keys [address] :as contact}]]
|
||||
(if address
|
||||
(assoc acc address contact)
|
||||
acc))
|
||||
{}
|
||||
contacts)))
|
||||
|
|
|
@ -137,107 +137,107 @@
|
|||
(spec/def ::device-UUID (spec/nilable string?))
|
||||
|
||||
(spec/def ::db (allowed-keys
|
||||
:opt
|
||||
[:contacts/contacts
|
||||
:contacts/new-identity
|
||||
:contacts/new-public-key-error
|
||||
:contacts/identity
|
||||
:contacts/ui-props
|
||||
:contacts/list-ui-props
|
||||
:contacts/click-handler
|
||||
:contacts/click-action
|
||||
:contacts/click-params
|
||||
:group/contact-groups
|
||||
:group/contact-group-id
|
||||
:group/group-type
|
||||
:group/selected-contacts
|
||||
:group/groups-order
|
||||
:accounts/accounts
|
||||
:accounts/create
|
||||
:accounts/recover
|
||||
:accounts/login
|
||||
:account/account
|
||||
:my-profile/profile
|
||||
:my-profile/default-name
|
||||
:my-profile/editing?
|
||||
:my-profile/advanced?
|
||||
:my-profile/seed
|
||||
:group-chat-profile/profile
|
||||
:group-chat-profile/editing?
|
||||
:networks/selected-network
|
||||
:networks/networks
|
||||
:node/after-start
|
||||
:node/after-stop
|
||||
:inbox/wnodes
|
||||
:inbox/password
|
||||
:inbox/sym-key-id
|
||||
:inbox/last-request
|
||||
:browser/browsers
|
||||
:browser/options
|
||||
:new/open-dapp
|
||||
:navigation/screen-params
|
||||
:transport/message-envelopes
|
||||
:transport/chats
|
||||
:transport/discovery-filter
|
||||
:desktop/desktop]
|
||||
:opt-un
|
||||
[::current-public-key
|
||||
::modal
|
||||
::was-modal?
|
||||
::rpc-url
|
||||
::web3
|
||||
::webview-bridge
|
||||
::status-module-initialized?
|
||||
::status-node-started?
|
||||
::keyboard-height
|
||||
::keyboard-max-height
|
||||
::tab-bar-visible?
|
||||
::network-status
|
||||
::mailserver-status
|
||||
::peers-count
|
||||
::sync-listening-started
|
||||
::sync-state
|
||||
::sync-data
|
||||
::network
|
||||
:navigation/view-id
|
||||
:navigation/navigation-stack
|
||||
:navigation/prev-tab-view-id
|
||||
:navigation/prev-view-id
|
||||
:qr/qr-codes
|
||||
:qr/qr-modal
|
||||
:qr/current-qr-context
|
||||
:chat/chats
|
||||
:chat/current-chat-id
|
||||
:chat/chat-id
|
||||
:chat/new-chat
|
||||
:chat/new-chat-name
|
||||
:chat/chat-animations
|
||||
:chat/chat-ui-props
|
||||
:chat/chat-list-ui-props
|
||||
:chat/layout-height
|
||||
:chat/expandable-view-height-to-value
|
||||
:chat/message-data
|
||||
:chat/message-status
|
||||
:chat/selected-participants
|
||||
:chat/chat-loaded-callbacks
|
||||
:chat/public-group-topic
|
||||
:chat/public-group-topic-error
|
||||
:chat/messages
|
||||
:chat/not-loaded-message-ids
|
||||
:chat/last-clock-value
|
||||
:chat/loaded-chats
|
||||
:chat/bot-db
|
||||
:commands/access-scope->commands-responses
|
||||
:discoveries/discoveries
|
||||
:discoveries/discover-search-tags
|
||||
:discoveries/discover-current-dapp
|
||||
:discoveries/tags
|
||||
:discoveries/current-tag
|
||||
:discoveries/request-discoveries-timer
|
||||
:wallet/wallet
|
||||
:wallet/wallet.transactions
|
||||
:wallet/wallet-selected-asset
|
||||
:prices/prices
|
||||
:prices/prices-loading?
|
||||
:notifications/notifications
|
||||
::device-UUID]))
|
||||
:opt
|
||||
[:contacts/contacts
|
||||
:contacts/new-identity
|
||||
:contacts/new-public-key-error
|
||||
:contacts/identity
|
||||
:contacts/ui-props
|
||||
:contacts/list-ui-props
|
||||
:contacts/click-handler
|
||||
:contacts/click-action
|
||||
:contacts/click-params
|
||||
:group/contact-groups
|
||||
:group/contact-group-id
|
||||
:group/group-type
|
||||
:group/selected-contacts
|
||||
:group/groups-order
|
||||
:accounts/accounts
|
||||
:accounts/create
|
||||
:accounts/recover
|
||||
:accounts/login
|
||||
:account/account
|
||||
:my-profile/profile
|
||||
:my-profile/default-name
|
||||
:my-profile/editing?
|
||||
:my-profile/advanced?
|
||||
:my-profile/seed
|
||||
:group-chat-profile/profile
|
||||
:group-chat-profile/editing?
|
||||
:networks/selected-network
|
||||
:networks/networks
|
||||
:node/after-start
|
||||
:node/after-stop
|
||||
:inbox/wnodes
|
||||
:inbox/password
|
||||
:inbox/sym-key-id
|
||||
:inbox/last-request
|
||||
:browser/browsers
|
||||
:browser/options
|
||||
:new/open-dapp
|
||||
:navigation/screen-params
|
||||
:transport/message-envelopes
|
||||
:transport/chats
|
||||
:transport/discovery-filter
|
||||
:desktop/desktop]
|
||||
:opt-un
|
||||
[::current-public-key
|
||||
::modal
|
||||
::was-modal?
|
||||
::rpc-url
|
||||
::web3
|
||||
::webview-bridge
|
||||
::status-module-initialized?
|
||||
::status-node-started?
|
||||
::keyboard-height
|
||||
::keyboard-max-height
|
||||
::tab-bar-visible?
|
||||
::network-status
|
||||
::mailserver-status
|
||||
::peers-count
|
||||
::sync-listening-started
|
||||
::sync-state
|
||||
::sync-data
|
||||
::network
|
||||
:navigation/view-id
|
||||
:navigation/navigation-stack
|
||||
:navigation/prev-tab-view-id
|
||||
:navigation/prev-view-id
|
||||
:qr/qr-codes
|
||||
:qr/qr-modal
|
||||
:qr/current-qr-context
|
||||
:chat/chats
|
||||
:chat/current-chat-id
|
||||
:chat/chat-id
|
||||
:chat/new-chat
|
||||
:chat/new-chat-name
|
||||
:chat/chat-animations
|
||||
:chat/chat-ui-props
|
||||
:chat/chat-list-ui-props
|
||||
:chat/layout-height
|
||||
:chat/expandable-view-height-to-value
|
||||
:chat/message-data
|
||||
:chat/message-status
|
||||
:chat/selected-participants
|
||||
:chat/chat-loaded-callbacks
|
||||
:chat/public-group-topic
|
||||
:chat/public-group-topic-error
|
||||
:chat/messages
|
||||
:chat/not-loaded-message-ids
|
||||
:chat/last-clock-value
|
||||
:chat/loaded-chats
|
||||
:chat/bot-db
|
||||
:commands/access-scope->commands-responses
|
||||
:discoveries/discoveries
|
||||
:discoveries/discover-search-tags
|
||||
:discoveries/discover-current-dapp
|
||||
:discoveries/tags
|
||||
:discoveries/current-tag
|
||||
:discoveries/request-discoveries-timer
|
||||
:wallet/wallet
|
||||
:wallet/wallet.transactions
|
||||
:wallet/wallet-selected-asset
|
||||
:prices/prices
|
||||
:prices/prices-loading?
|
||||
:notifications/notifications
|
||||
::device-UUID]))
|
||||
|
|
|
@ -13,14 +13,14 @@
|
|||
[status-im.ui.components.react :as react]))
|
||||
|
||||
(views/defview toolbar-chat-view []
|
||||
(views/letsubs [{:keys [chat-id name public-key public? group-chat]} [:get-current-chat]
|
||||
(views/letsubs [{:keys [chat-id name public-key public? group-chat]} [:get-current-chat]
|
||||
{:keys [pending?]} [:get-current-chat-contact]]
|
||||
(let [chat-name (str
|
||||
(if public? "#" "")
|
||||
(if (string/blank? name)
|
||||
(gfycat.core/generate-gfy public-key)
|
||||
(or name
|
||||
"Chat name")))]
|
||||
(if public? "#" "")
|
||||
(if (string/blank? name)
|
||||
(gfycat.core/generate-gfy public-key)
|
||||
(or name
|
||||
"Chat name")))]
|
||||
[react/view {:style {:align-items :center :padding 11 :justify-content :center}}
|
||||
[react/view {:style {:flex-direction :row}}
|
||||
(when public?
|
||||
|
@ -77,31 +77,31 @@
|
|||
[react/view {:style {:height 1 :background-color "#e8ebec"}}]]
|
||||
(when (= content-type constants/text-content-type)
|
||||
(reagent.core/create-class
|
||||
{:component-did-mount
|
||||
#(when (and message-id
|
||||
chat-id
|
||||
(not outgoing)
|
||||
(not= :seen message-status)
|
||||
(not= :seen (keyword (get-in user-statuses [current-public-key :status]))))
|
||||
(re-frame/dispatch [:send-seen! {:chat-id chat-id
|
||||
:from from
|
||||
:message-id message-id}]))
|
||||
:reagent-render
|
||||
(fn []
|
||||
^{:key (str "message" message-id)}
|
||||
[react/view {:style {:flex-direction :row :flex 1 :margin-vertical 12}}
|
||||
(if outgoing
|
||||
[my-photo from]
|
||||
[member-photo from])
|
||||
[react/view {:style {:padding-horizontal 12 :background-color :white :border-radius 8 :flex 1}}
|
||||
[react/view {:style {:flex-direction :row}}
|
||||
[message-author-name message]
|
||||
[react/view {:style {:flex 1}}]
|
||||
[react/text {:style {:color styles/color-gray4 :font-size 12}} (time/timestamp->time timestamp)]]
|
||||
{:component-did-mount
|
||||
#(when (and message-id
|
||||
chat-id
|
||||
(not outgoing)
|
||||
(not= :seen message-status)
|
||||
(not= :seen (keyword (get-in user-statuses [current-public-key :status]))))
|
||||
(re-frame/dispatch [:send-seen! {:chat-id chat-id
|
||||
:from from
|
||||
:message-id message-id}]))
|
||||
:reagent-render
|
||||
(fn []
|
||||
^{:key (str "message" message-id)}
|
||||
[react/view {:style {:flex-direction :row :flex 1 :margin-vertical 12}}
|
||||
(if outgoing
|
||||
[my-photo from]
|
||||
[member-photo from])
|
||||
[react/view {:style {:padding-horizontal 12 :background-color :white :border-radius 8 :flex 1}}
|
||||
[react/view {:style {:flex-direction :row}}
|
||||
[message-author-name message]
|
||||
[react/view {:style {:flex 1}}]
|
||||
[react/text {:style {:color styles/color-gray4 :font-size 12}} (time/timestamp->time timestamp)]]
|
||||
;;TODO use https://github.com/status-im/status-react/pull/3299
|
||||
;;[rn-hl/hyperlink {:linkStyle {:color "#2980b9"} :on-press #(re-frame/dispatch [:show-link-dialog %1])}
|
||||
[react/text
|
||||
text]]])}))))
|
||||
[react/text
|
||||
text]]])}))))
|
||||
|
||||
(views/defview messages-view [{:keys [chat-id group-chat]}]
|
||||
(views/letsubs [chat-id* (atom nil)
|
||||
|
@ -116,20 +116,20 @@
|
|||
[react/view {:style {:flex 1 :background-color :white :margin-horizontal 16}}
|
||||
[react/scroll-view {:scrollEventThrottle 16
|
||||
:on-scroll (fn [e]
|
||||
(let [ne (.-nativeEvent e)
|
||||
y (.-y (.-contentOffset ne))]
|
||||
(when (zero? y)
|
||||
(when @scroll-timer (js/clearTimeout @scroll-timer))
|
||||
(reset! scroll-timer (js/setTimeout #(re-frame/dispatch [:load-more-messages]) 300)))
|
||||
(reset! scroll-height (+ y (.-height (.-layoutMeasurement ne))))))
|
||||
(let [ne (.-nativeEvent e)
|
||||
y (.-y (.-contentOffset ne))]
|
||||
(when (zero? y)
|
||||
(when @scroll-timer (js/clearTimeout @scroll-timer))
|
||||
(reset! scroll-timer (js/setTimeout #(re-frame/dispatch [:load-more-messages]) 300)))
|
||||
(reset! scroll-height (+ y (.-height (.-layoutMeasurement ne))))))
|
||||
:on-content-size-change #(when (or (not @scroll-height) (< (- %2 @scroll-height) 500))
|
||||
(.scrollToEnd @scroll-ref))
|
||||
:ref #(reset! scroll-ref %)}
|
||||
[react/view {:style {:padding-vertical 60}}
|
||||
(doall
|
||||
(for [[index {:keys [from content message-id] :as message-obj}] (map-indexed vector (reverse @messages))]
|
||||
^{:key (str message index)}
|
||||
[message content (= from @current-public-key) (assoc message-obj :group-chat group-chat)]))]]])))
|
||||
(for [[index {:keys [from content message-id] :as message-obj}] (map-indexed vector (reverse @messages))]
|
||||
^{:key (str message index)}
|
||||
[message content (= from @current-public-key) (assoc message-obj :group-chat group-chat)]))]]])))
|
||||
|
||||
(views/defview chat-text-input []
|
||||
(views/letsubs [{:keys [input-text]} [:get-current-chat]
|
||||
|
@ -157,10 +157,10 @@
|
|||
text (.-text native-event)]
|
||||
(re-frame/dispatch [:set-chat-input-text text])))}]]
|
||||
[react/touchable-highlight {:on-press (fn []
|
||||
(js/setTimeout #(do (.clear @inp-ref)(.focus @inp-ref)) 200)
|
||||
(js/setTimeout #(do (.clear @inp-ref) (.focus @inp-ref)) 200)
|
||||
(re-frame/dispatch [:send-current-message]))}
|
||||
[react/view {:style {:margin-left 16 :width 30 :height 30 :border-radius 15 :background-color "#eef2f5" :align-items :center
|
||||
:justify-content :center :transform [{ :rotate "90deg"}]}}
|
||||
:justify-content :center :transform [{:rotate "90deg"}]}}
|
||||
[icons/icon :icons/arrow-left]]]]]))
|
||||
|
||||
(views/defview chat-view []
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
|
||||
(views/defview chat-list-item-inner-view [{:keys [chat-id name group-chat public? public-key]}]
|
||||
(let [name (str
|
||||
(if public? "#" "")
|
||||
(or name
|
||||
(gfycat/generate-gfy public-key)))]
|
||||
(if public? "#" "")
|
||||
(or name
|
||||
(gfycat/generate-gfy public-key)))]
|
||||
[react/view {:style {:padding 12 :background-color :white :flex-direction :row :align-items :center}}
|
||||
(when public?
|
||||
[icons/icon :icons/public-chat])
|
||||
|
|
|
@ -37,8 +37,8 @@
|
|||
[my-profile-info current-account]]
|
||||
[react/view {:style {:height 1 :background-color "#e8ebec" :margin-horizontal 16}}]
|
||||
[react/touchable-highlight {:on-press #(keychain/get-encryption-key-then
|
||||
(fn [encryption-key]
|
||||
(re-frame/dispatch [:logout encryption-key])))
|
||||
(fn [encryption-key]
|
||||
(re-frame/dispatch [:logout encryption-key])))
|
||||
:style {:margin-top 60}}
|
||||
[react/view
|
||||
[react/text {:style {:color :red}} "Log out"]]]]))
|
||||
|
|
|
@ -88,25 +88,25 @@
|
|||
;;;; FX
|
||||
|
||||
(re-frame/reg-fx
|
||||
:call-jail
|
||||
(fn [{:keys [callback-event-creator] :as opts}]
|
||||
(status/call-jail
|
||||
(-> opts
|
||||
(dissoc :callback-event-creator)
|
||||
(assoc :callback
|
||||
(fn [jail-response]
|
||||
(when-let [event (callback-event-creator jail-response)]
|
||||
(re-frame/dispatch event))))))))
|
||||
:call-jail
|
||||
(fn [{:keys [callback-event-creator] :as opts}]
|
||||
(status/call-jail
|
||||
(-> opts
|
||||
(dissoc :callback-event-creator)
|
||||
(assoc :callback
|
||||
(fn [jail-response]
|
||||
(when-let [event (callback-event-creator jail-response)]
|
||||
(re-frame/dispatch event))))))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:call-jail-function
|
||||
call-jail-function)
|
||||
:call-jail-function
|
||||
call-jail-function)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:call-jail-function-n
|
||||
(fn [opts-seq]
|
||||
(doseq [opts opts-seq]
|
||||
(call-jail-function opts))))
|
||||
:call-jail-function-n
|
||||
(fn [opts-seq]
|
||||
(doseq [opts opts-seq]
|
||||
(call-jail-function opts))))
|
||||
|
||||
(defn- http-get [{:keys [url response-validator success-event-creator failure-event-creator timeout-ms]}]
|
||||
(let [on-success #(re-frame/dispatch (success-event-creator %))
|
||||
|
@ -116,69 +116,69 @@
|
|||
(http/get url on-success on-error opts)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:http-get
|
||||
http-get)
|
||||
:http-get
|
||||
http-get)
|
||||
|
||||
(re-frame/reg-fx
|
||||
:http-get-n
|
||||
(fn [calls]
|
||||
(doseq [call calls]
|
||||
(http-get call))))
|
||||
:http-get-n
|
||||
(fn [calls]
|
||||
(doseq [call calls]
|
||||
(http-get call))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::init-store
|
||||
(fn [encryption-key]
|
||||
(data-store/init encryption-key)))
|
||||
::init-store
|
||||
(fn [encryption-key]
|
||||
(data-store/init encryption-key)))
|
||||
|
||||
(defn move-to-internal-storage [config]
|
||||
(status/move-to-internal-storage
|
||||
#(status/start-node config)))
|
||||
#(status/start-node config)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::initialize-keychain-fx
|
||||
(fn []
|
||||
(keychain/get-encryption-key-then
|
||||
(fn [encryption-key]
|
||||
(re-frame/dispatch [:initialize-app encryption-key])))))
|
||||
::initialize-keychain-fx
|
||||
(fn []
|
||||
(keychain/get-encryption-key-then
|
||||
(fn [encryption-key]
|
||||
(re-frame/dispatch [:initialize-app encryption-key])))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::got-encryption-key-fx
|
||||
(fn [{:keys [encryption-key callback]}]
|
||||
(callback encryption-key)))
|
||||
::got-encryption-key-fx
|
||||
(fn [{:keys [encryption-key callback]}]
|
||||
(callback encryption-key)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:initialize-geth-fx
|
||||
(fn [config]
|
||||
:initialize-geth-fx
|
||||
(fn [config]
|
||||
;;TODO get rid of this, because we don't need this anymore
|
||||
(status/should-move-to-internal-storage?
|
||||
(fn [should-move?]
|
||||
(if should-move?
|
||||
(re-frame/dispatch [:request-permissions {:permissions [:read-external-storage]
|
||||
:on-allowed #(move-to-internal-storage config)}])
|
||||
(status/start-node config))))))
|
||||
(status/should-move-to-internal-storage?
|
||||
(fn [should-move?]
|
||||
(if should-move?
|
||||
(re-frame/dispatch [:request-permissions {:permissions [:read-external-storage]
|
||||
:on-allowed #(move-to-internal-storage config)}])
|
||||
(status/start-node config))))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::status-module-initialized-fx
|
||||
(fn [_]
|
||||
(status/module-initialized!)))
|
||||
::status-module-initialized-fx
|
||||
(fn [_]
|
||||
(status/module-initialized!)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:request-permissions-fx
|
||||
(fn [options]
|
||||
(permissions/request-permissions options)))
|
||||
:request-permissions-fx
|
||||
(fn [options]
|
||||
(permissions/request-permissions options)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::request-notifications-fx
|
||||
(fn [_]
|
||||
(notifications/request-permissions)))
|
||||
::request-notifications-fx
|
||||
(fn [_]
|
||||
(notifications/request-permissions)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::testfairy-alert
|
||||
(fn [_]
|
||||
(when config/testfairy-enabled?
|
||||
(utils/show-popup
|
||||
(i18n/label :testfairy-title)
|
||||
(i18n/label :testfairy-message)))))
|
||||
::testfairy-alert
|
||||
(fn [_]
|
||||
(when config/testfairy-enabled?
|
||||
(utils/show-popup
|
||||
(i18n/label :testfairy-title)
|
||||
(i18n/label :testfairy-message)))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::init-device-UUID
|
||||
|
@ -186,47 +186,46 @@
|
|||
(status/get-device-UUID #(re-frame/dispatch [:set :device-UUID %]))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::get-fcm-token-fx
|
||||
(fn [_]
|
||||
(notifications/get-fcm-token)))
|
||||
::get-fcm-token-fx
|
||||
(fn [_]
|
||||
(notifications/get-fcm-token)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:show-error
|
||||
(fn [content]
|
||||
(utils/show-popup "Error" content)))
|
||||
:show-error
|
||||
(fn [content]
|
||||
(utils/show-popup "Error" content)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:show-confirmation
|
||||
(fn [{:keys [title content confirm-button-text on-accept on-cancel]}]
|
||||
(utils/show-confirmation title content confirm-button-text on-accept on-cancel)))
|
||||
|
||||
:show-confirmation
|
||||
(fn [{:keys [title content confirm-button-text on-accept on-cancel]}]
|
||||
(utils/show-confirmation title content confirm-button-text on-accept on-cancel)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:close-application
|
||||
(fn [_]
|
||||
(status/close-application)))
|
||||
:close-application
|
||||
(fn [_]
|
||||
(status/close-application)))
|
||||
|
||||
;;;; Handlers
|
||||
|
||||
(handlers/register-handler-db
|
||||
:set
|
||||
(fn [db [_ k v]]
|
||||
(assoc db k v)))
|
||||
:set
|
||||
(fn [db [_ k v]]
|
||||
(assoc db k v)))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:set-in
|
||||
(fn [db [_ path v]]
|
||||
(assoc-in db path v)))
|
||||
:set-in
|
||||
(fn [db [_ path v]]
|
||||
(assoc-in db path v)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:initialize-keychain
|
||||
(fn [_ _]
|
||||
{::initialize-keychain-fx nil}))
|
||||
:initialize-keychain
|
||||
(fn [_ _]
|
||||
{::initialize-keychain-fx nil}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:got-encryption-key
|
||||
(fn [_ [_ opts]]
|
||||
{::got-encryption-key-fx opts}))
|
||||
:got-encryption-key
|
||||
(fn [_ [_ opts]]
|
||||
{::got-encryption-key-fx opts}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:initialize-app
|
||||
|
@ -240,109 +239,109 @@
|
|||
[:initialize-geth]]}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:logout
|
||||
(fn [{:keys [db] :as cofx} [_ encryption-key]]
|
||||
(let [{:transport/keys [chats]} db
|
||||
sharing-usage-data? (get-in db [:account/account :sharing-usage-data?])]
|
||||
(handlers-macro/merge-fx cofx
|
||||
{:dispatch-n (concat [[:initialize-db encryption-key]
|
||||
[:load-accounts]
|
||||
[:listen-to-network-status]
|
||||
[:navigate-to :accounts]]
|
||||
(when sharing-usage-data?
|
||||
[[:unregister-mixpanel-tracking]]))}
|
||||
(transport/stop-whisper)))))
|
||||
:logout
|
||||
(fn [{:keys [db] :as cofx} [_ encryption-key]]
|
||||
(let [{:transport/keys [chats]} db
|
||||
sharing-usage-data? (get-in db [:account/account :sharing-usage-data?])]
|
||||
(handlers-macro/merge-fx cofx
|
||||
{:dispatch-n (concat [[:initialize-db encryption-key]
|
||||
[:load-accounts]
|
||||
[:listen-to-network-status]
|
||||
[:navigate-to :accounts]]
|
||||
(when sharing-usage-data?
|
||||
[[:unregister-mixpanel-tracking]]))}
|
||||
(transport/stop-whisper)))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:initialize-db
|
||||
(fn [{{:keys [status-module-initialized? status-node-started?
|
||||
network-status network]
|
||||
:or {network (get app-db :network)}} :db}
|
||||
[_ encryption-key]]
|
||||
{::init-store encryption-key
|
||||
:db (assoc app-db
|
||||
:contacts/contacts {}
|
||||
:network-status network-status
|
||||
:status-module-initialized? (or platform/ios? js/goog.DEBUG status-module-initialized?)
|
||||
:status-node-started? status-node-started?
|
||||
:network network)}))
|
||||
:initialize-db
|
||||
(fn [{{:keys [status-module-initialized? status-node-started?
|
||||
network-status network]
|
||||
:or {network (get app-db :network)}} :db}
|
||||
[_ encryption-key]]
|
||||
{::init-store encryption-key
|
||||
:db (assoc app-db
|
||||
:contacts/contacts {}
|
||||
:network-status network-status
|
||||
:status-module-initialized? (or platform/ios? js/goog.DEBUG status-module-initialized?)
|
||||
:status-node-started? status-node-started?
|
||||
:network network)}))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:initialize-account-db
|
||||
(fn [{:keys [accounts/accounts accounts/create contacts/contacts networks/networks
|
||||
network network-status view-id navigation-stack
|
||||
access-scope->commands-responses
|
||||
status-module-initialized? status-node-started?]
|
||||
:or [network (get app-db :network)]} [_ address]]
|
||||
(let [console-contact (get contacts constants/console-chat-id)
|
||||
current-account (accounts address)]
|
||||
(cond-> (assoc app-db
|
||||
:access-scope->commands-responses access-scope->commands-responses
|
||||
:current-public-key (:public-key current-account)
|
||||
:view-id view-id
|
||||
:navigation-stack navigation-stack
|
||||
:status-module-initialized? (or platform/ios? js/goog.DEBUG status-module-initialized?)
|
||||
:status-node-started? status-node-started?
|
||||
:accounts/create create
|
||||
:networks/networks networks
|
||||
:account/account current-account
|
||||
:network-status network-status
|
||||
:network network)
|
||||
console-contact
|
||||
(assoc :contacts/contacts {constants/console-chat-id console-contact})))))
|
||||
:initialize-account-db
|
||||
(fn [{:keys [accounts/accounts accounts/create contacts/contacts networks/networks
|
||||
network network-status view-id navigation-stack
|
||||
access-scope->commands-responses
|
||||
status-module-initialized? status-node-started?]
|
||||
:or [network (get app-db :network)]} [_ address]]
|
||||
(let [console-contact (get contacts constants/console-chat-id)
|
||||
current-account (accounts address)]
|
||||
(cond-> (assoc app-db
|
||||
:access-scope->commands-responses access-scope->commands-responses
|
||||
:current-public-key (:public-key current-account)
|
||||
:view-id view-id
|
||||
:navigation-stack navigation-stack
|
||||
:status-module-initialized? (or platform/ios? js/goog.DEBUG status-module-initialized?)
|
||||
:status-node-started? status-node-started?
|
||||
:accounts/create create
|
||||
:networks/networks networks
|
||||
:account/account current-account
|
||||
:network-status network-status
|
||||
:network network)
|
||||
console-contact
|
||||
(assoc :contacts/contacts {constants/console-chat-id console-contact})))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:initialize-account
|
||||
(fn [_ [_ address events-after]]
|
||||
{:dispatch-n (cond-> [[:initialize-account-db address]
|
||||
[:initialize-protocol address]
|
||||
[:initialize-sync-listener]
|
||||
[:load-contacts]
|
||||
[:load-contact-groups]
|
||||
[:initialize-chats]
|
||||
[:initialize-browsers]
|
||||
[:initialize-debugging {:address address}]
|
||||
[:send-account-update-if-needed]
|
||||
[:process-pending-messages]
|
||||
[:update-wallet]
|
||||
[:update-transactions]
|
||||
[:get-fcm-token]
|
||||
[:update-sign-in-time]]
|
||||
(seq events-after) (into events-after))}))
|
||||
:initialize-account
|
||||
(fn [_ [_ address events-after]]
|
||||
{:dispatch-n (cond-> [[:initialize-account-db address]
|
||||
[:initialize-protocol address]
|
||||
[:initialize-sync-listener]
|
||||
[:load-contacts]
|
||||
[:load-contact-groups]
|
||||
[:initialize-chats]
|
||||
[:initialize-browsers]
|
||||
[:initialize-debugging {:address address}]
|
||||
[:send-account-update-if-needed]
|
||||
[:process-pending-messages]
|
||||
[:update-wallet]
|
||||
[:update-transactions]
|
||||
[:get-fcm-token]
|
||||
[:update-sign-in-time]]
|
||||
(seq events-after) (into events-after))}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:initialize-views
|
||||
(fn [{{:accounts/keys [accounts] :as db} :db} _]
|
||||
{:db (if (empty? accounts)
|
||||
(assoc db :view-id :intro :navigation-stack (list :intro))
|
||||
(let [{:keys [address photo-path name]} (first (sort-by :last-sign-in > (vals accounts)))]
|
||||
(-> db
|
||||
(assoc :view-id :login
|
||||
:navigation-stack (list :login))
|
||||
(update :accounts/login assoc
|
||||
:address address
|
||||
:photo-path photo-path
|
||||
:name name))))}))
|
||||
:initialize-views
|
||||
(fn [{{:accounts/keys [accounts] :as db} :db} _]
|
||||
{:db (if (empty? accounts)
|
||||
(assoc db :view-id :intro :navigation-stack (list :intro))
|
||||
(let [{:keys [address photo-path name]} (first (sort-by :last-sign-in > (vals accounts)))]
|
||||
(-> db
|
||||
(assoc :view-id :login
|
||||
:navigation-stack (list :login))
|
||||
(update :accounts/login assoc
|
||||
:address address
|
||||
:photo-path photo-path
|
||||
:name name))))}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:initialize-geth
|
||||
(fn [{db :db} _]
|
||||
(let [default-networks (:networks/networks db)
|
||||
default-network (:network db)
|
||||
{:keys [network networks]} (:account/account db)
|
||||
network-config (or (get-in networks [network :config])
|
||||
(get-in default-networks [default-network :config]))]
|
||||
{:initialize-geth-fx network-config})))
|
||||
:initialize-geth
|
||||
(fn [{db :db} _]
|
||||
(let [default-networks (:networks/networks db)
|
||||
default-network (:network db)
|
||||
{:keys [network networks]} (:account/account db)
|
||||
network-config (or (get-in networks [network :config])
|
||||
(get-in default-networks [default-network :config]))]
|
||||
{:initialize-geth-fx network-config})))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:webview-geo-permissions-granted
|
||||
(fn [{{:keys [webview-bridge]} :db} _]
|
||||
(.geoPermissionsGranted webview-bridge)))
|
||||
:webview-geo-permissions-granted
|
||||
(fn [{{:keys [webview-bridge]} :db} _]
|
||||
(.geoPermissionsGranted webview-bridge)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:get-fcm-token
|
||||
(fn [_ _]
|
||||
{::get-fcm-token-fx nil}))
|
||||
:get-fcm-token
|
||||
(fn [_ _]
|
||||
{::get-fcm-token-fx nil}))
|
||||
|
||||
;; Because we send command to jail in params and command `:ref` is a lookup vector with
|
||||
;; keyword in it (for example `["transactor" :command 51 "send"]`), we lose that keyword
|
||||
|
@ -370,68 +369,68 @@
|
|||
(log/debug "Unknown jail signal " event))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:signal-event
|
||||
(fn [_ [_ event-str]]
|
||||
(log/debug :event-str event-str)
|
||||
(instabug/log (str "Signal event: " event-str))
|
||||
(let [{:keys [type event]} (types/json->clj event-str)
|
||||
to-dispatch (case type
|
||||
"sign-request.queued" [:sign-request-queued event]
|
||||
"sign-request.failed" [:sign-request-failed event]
|
||||
"node.started" [:status-node-started]
|
||||
"node.stopped" [:status-node-stopped]
|
||||
"module.initialized" [:status-module-initialized]
|
||||
"jail.signal" (handle-jail-signal event)
|
||||
"envelope.sent" [:signals/envelope-status (:hash event) :sent]
|
||||
"envelope.expired" [:signals/envelope-status (:hash event) :not-sent]
|
||||
(log/debug "Event " type " not handled"))]
|
||||
(when to-dispatch
|
||||
{:dispatch to-dispatch}))))
|
||||
:signal-event
|
||||
(fn [_ [_ event-str]]
|
||||
(log/debug :event-str event-str)
|
||||
(instabug/log (str "Signal event: " event-str))
|
||||
(let [{:keys [type event]} (types/json->clj event-str)
|
||||
to-dispatch (case type
|
||||
"sign-request.queued" [:sign-request-queued event]
|
||||
"sign-request.failed" [:sign-request-failed event]
|
||||
"node.started" [:status-node-started]
|
||||
"node.stopped" [:status-node-stopped]
|
||||
"module.initialized" [:status-module-initialized]
|
||||
"jail.signal" (handle-jail-signal event)
|
||||
"envelope.sent" [:signals/envelope-status (:hash event) :sent]
|
||||
"envelope.expired" [:signals/envelope-status (:hash event) :not-sent]
|
||||
(log/debug "Event " type " not handled"))]
|
||||
(when to-dispatch
|
||||
{:dispatch to-dispatch}))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:status-module-initialized
|
||||
(fn [{:keys [db]} _]
|
||||
{:db (assoc db :status-module-initialized? true)
|
||||
::status-module-initialized-fx nil}))
|
||||
:status-module-initialized
|
||||
(fn [{:keys [db]} _]
|
||||
{:db (assoc db :status-module-initialized? true)
|
||||
::status-module-initialized-fx nil}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:status-node-started
|
||||
(fn [{{:node/keys [after-start] :as db} :db} _]
|
||||
(merge {:db (assoc db :status-node-started? true)}
|
||||
(when after-start {:dispatch-n [after-start]}))))
|
||||
:status-node-started
|
||||
(fn [{{:node/keys [after-start] :as db} :db} _]
|
||||
(merge {:db (assoc db :status-node-started? true)}
|
||||
(when after-start {:dispatch-n [after-start]}))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:status-node-stopped
|
||||
(fn [{{:node/keys [after-stop]} :db} _]
|
||||
(when after-stop {:dispatch-n [after-stop]})))
|
||||
:status-node-stopped
|
||||
(fn [{{:node/keys [after-stop]} :db} _]
|
||||
(when after-stop {:dispatch-n [after-stop]})))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:app-state-change
|
||||
(fn [_ [_ state]]
|
||||
(status/app-state-change state)))
|
||||
:app-state-change
|
||||
(fn [_ [_ state]]
|
||||
(status/app-state-change state)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:request-permissions
|
||||
(fn [_ [_ options]]
|
||||
{:request-permissions-fx options}))
|
||||
:request-permissions
|
||||
(fn [_ [_ options]]
|
||||
{:request-permissions-fx options}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:request-notifications
|
||||
(fn [_ _]
|
||||
{::request-notifications-fx {}}))
|
||||
:request-notifications
|
||||
(fn [_ _]
|
||||
{::request-notifications-fx {}}))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:set-swipe-position
|
||||
[re-frame/trim-v]
|
||||
(fn [db [item-id value]]
|
||||
(assoc-in db [:chat-animations item-id :delete-swiped] value)))
|
||||
:set-swipe-position
|
||||
[re-frame/trim-v]
|
||||
(fn [db [item-id value]]
|
||||
(assoc-in db [:chat-animations item-id :delete-swiped] value)))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:show-tab-bar
|
||||
(fn [db _]
|
||||
(assoc db :tab-bar-visible? true)))
|
||||
:show-tab-bar
|
||||
(fn [db _]
|
||||
(assoc db :tab-bar-visible? true)))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:hide-tab-bar
|
||||
(fn [db _]
|
||||
(assoc db :tab-bar-visible? false)))
|
||||
:hide-tab-bar
|
||||
(fn [db _]
|
||||
(assoc db :tab-bar-visible? false)))
|
||||
|
|
|
@ -8,66 +8,65 @@
|
|||
[status-im.utils.handlers :as handlers]
|
||||
[status-im.utils.handlers-macro :as handlers-macro]))
|
||||
|
||||
|
||||
;;;; Handlers
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:show-group-chat-profile
|
||||
[re-frame/trim-v]
|
||||
(fn [{:keys [db] :as cofx} [chat-id]]
|
||||
{:db (-> db
|
||||
(assoc :new-chat-name (get-in db [:chats chat-id :name])
|
||||
:group/group-type :chat-group)
|
||||
(navigation/navigate-to :group-chat-profile))}))
|
||||
:show-group-chat-profile
|
||||
[re-frame/trim-v]
|
||||
(fn [{:keys [db] :as cofx} [chat-id]]
|
||||
{:db (-> db
|
||||
(assoc :new-chat-name (get-in db [:chats chat-id :name])
|
||||
:group/group-type :chat-group)
|
||||
(navigation/navigate-to :group-chat-profile))}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:add-new-group-chat-participants
|
||||
[(re-frame/inject-cofx :random-id)]
|
||||
(fn [{{:keys [current-chat-id selected-participants] :as db} :db now :now message-id :random-id :as cofx} _]
|
||||
(let [participants (concat (get-in db [:chats current-chat-id :contacts]) selected-participants)
|
||||
contacts (:contacts/contacts db)
|
||||
added-participants-names (map #(get-in contacts [% :name]) selected-participants)]
|
||||
(handlers-macro/merge-fx cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:chats current-chat-id :contacts] participants)
|
||||
(assoc :selected-participants #{}))
|
||||
:data-store/add-chat-contacts (select-keys db [:current-chat-id :selected-participants])}
|
||||
(models.message/receive
|
||||
(models.message/system-message current-chat-id message-id now
|
||||
(str "You've added " (apply str (interpose ", " added-participants-names)))))
|
||||
(transport/send (group-chat/GroupAdminUpdate. nil participants) current-chat-id)))))
|
||||
:add-new-group-chat-participants
|
||||
[(re-frame/inject-cofx :random-id)]
|
||||
(fn [{{:keys [current-chat-id selected-participants] :as db} :db now :now message-id :random-id :as cofx} _]
|
||||
(let [participants (concat (get-in db [:chats current-chat-id :contacts]) selected-participants)
|
||||
contacts (:contacts/contacts db)
|
||||
added-participants-names (map #(get-in contacts [% :name]) selected-participants)]
|
||||
(handlers-macro/merge-fx cofx
|
||||
{:db (-> db
|
||||
(assoc-in [:chats current-chat-id :contacts] participants)
|
||||
(assoc :selected-participants #{}))
|
||||
:data-store/add-chat-contacts (select-keys db [:current-chat-id :selected-participants])}
|
||||
(models.message/receive
|
||||
(models.message/system-message current-chat-id message-id now
|
||||
(str "You've added " (apply str (interpose ", " added-participants-names)))))
|
||||
(transport/send (group-chat/GroupAdminUpdate. nil participants) current-chat-id)))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:remove-group-chat-participants
|
||||
[re-frame/trim-v (re-frame/inject-cofx :random-id)]
|
||||
(fn [{{:keys [current-chat-id] :as db} :db now :now message-id :random-id :as cofx} [removed-participants]]
|
||||
(let [participants (remove removed-participants (get-in db [:chats current-chat-id :contacts]))
|
||||
contacts (:contacts/contacts db)
|
||||
removed-participants-names (map #(get-in contacts [% :name]) removed-participants)]
|
||||
(handlers-macro/merge-fx cofx
|
||||
{:db (assoc-in db [:chats current-chat-id :contacts] participants)
|
||||
:data-store/remove-chat-contacts [current-chat-id removed-participants]}
|
||||
(models.message/receive
|
||||
(models.message/system-message current-chat-id message-id now
|
||||
(str "You've removed " (apply str (interpose ", " removed-participants-names)))))
|
||||
(transport/send (group-chat/GroupAdminUpdate. nil participants) current-chat-id)))))
|
||||
:remove-group-chat-participants
|
||||
[re-frame/trim-v (re-frame/inject-cofx :random-id)]
|
||||
(fn [{{:keys [current-chat-id] :as db} :db now :now message-id :random-id :as cofx} [removed-participants]]
|
||||
(let [participants (remove removed-participants (get-in db [:chats current-chat-id :contacts]))
|
||||
contacts (:contacts/contacts db)
|
||||
removed-participants-names (map #(get-in contacts [% :name]) removed-participants)]
|
||||
(handlers-macro/merge-fx cofx
|
||||
{:db (assoc-in db [:chats current-chat-id :contacts] participants)
|
||||
:data-store/remove-chat-contacts [current-chat-id removed-participants]}
|
||||
(models.message/receive
|
||||
(models.message/system-message current-chat-id message-id now
|
||||
(str "You've removed " (apply str (interpose ", " removed-participants-names)))))
|
||||
(transport/send (group-chat/GroupAdminUpdate. nil participants) current-chat-id)))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:set-group-chat-name
|
||||
(fn [{{:keys [current-chat-id] :as db} :db} [_ new-chat-name]]
|
||||
{:db (assoc-in db [:chats current-chat-id :name] new-chat-name)
|
||||
:data-store/save-chat-property [current-chat-id :name new-chat-name]}))
|
||||
:set-group-chat-name
|
||||
(fn [{{:keys [current-chat-id] :as db} :db} [_ new-chat-name]]
|
||||
{:db (assoc-in db [:chats current-chat-id :name] new-chat-name)
|
||||
:data-store/save-chat-property [current-chat-id :name new-chat-name]}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:clear-history
|
||||
(fn [{{:keys [current-chat-id] :as db} :db} _]
|
||||
{:db (assoc-in db [:chats current-chat-id :messages] {})
|
||||
:data-store/hide-messages current-chat-id}))
|
||||
:clear-history
|
||||
(fn [{{:keys [current-chat-id] :as db} :db} _]
|
||||
{:db (assoc-in db [:chats current-chat-id :messages] {})
|
||||
:data-store/hide-messages current-chat-id}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:clear-history?
|
||||
(fn [_ _]
|
||||
{:show-confirmation {:title (i18n/label :t/clear-history-confirmation)
|
||||
:content (i18n/label :t/clear-group-history-confirmation)
|
||||
:confirm-button-text (i18n/label :t/clear)
|
||||
:on-accept #(re-frame/dispatch [:clear-history])}}))
|
||||
:clear-history?
|
||||
(fn [_ _]
|
||||
{:show-confirmation {:title (i18n/label :t/clear-history-confirmation)
|
||||
:content (i18n/label :t/clear-group-history-confirmation)
|
||||
:confirm-button-text (i18n/label :t/clear)
|
||||
:on-accept #(re-frame/dispatch [:clear-history])}}))
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
[status-im.constants :refer [max-chat-name-length]]))
|
||||
|
||||
(reg-sub
|
||||
:selected-participant
|
||||
(fn [db]
|
||||
(let [identity (first (:selected-participants db))]
|
||||
(get-in db [:contacts/contacts identity]))))
|
||||
:selected-participant
|
||||
(fn [db]
|
||||
(let [identity (first (:selected-participants db))]
|
||||
(get-in db [:contacts/contacts identity]))))
|
||||
|
||||
(defn get-chat-name-validation-messages [chat-name]
|
||||
(filter some?
|
||||
|
@ -16,18 +16,18 @@
|
|||
"Chat name is too long"))))
|
||||
|
||||
(reg-sub
|
||||
:new-chat-name
|
||||
(fn [db]
|
||||
(:new-chat-name db)))
|
||||
:new-chat-name
|
||||
(fn [db]
|
||||
(:new-chat-name db)))
|
||||
|
||||
(reg-sub
|
||||
:new-chat-name-validation-messages
|
||||
:<- [:new-chat-name]
|
||||
(fn [chat-name]
|
||||
(get-chat-name-validation-messages chat-name)))
|
||||
:new-chat-name-validation-messages
|
||||
:<- [:new-chat-name]
|
||||
(fn [chat-name]
|
||||
(get-chat-name-validation-messages chat-name)))
|
||||
|
||||
(reg-sub
|
||||
:new-chat-name-valid?
|
||||
:<- [:new-chat-name]
|
||||
(fn [chat-name]
|
||||
(zero? (count (get-chat-name-validation-messages chat-name)))))
|
||||
:new-chat-name-valid?
|
||||
:<- [:new-chat-name]
|
||||
(fn [chat-name]
|
||||
(zero? (count (get-chat-name-validation-messages chat-name)))))
|
||||
|
|
|
@ -13,16 +13,16 @@
|
|||
(spec/def :group/name :global/not-empty-string)
|
||||
(spec/def :group/timestamp int?)
|
||||
(spec/def :group/pending? boolean?)
|
||||
(spec/def :group/order int?)
|
||||
(spec/def :group/order int?)
|
||||
|
||||
(spec/def :group/contact :global/not-empty-string)
|
||||
|
||||
(spec/def :group/contacts (spec/nilable (spec/* :group/contact)))
|
||||
|
||||
(spec/def :group/contact-group (allowed-keys
|
||||
:req-un [:group/group-id :group/name :group/timestamp
|
||||
:group/order :group/contacts]
|
||||
:opt-un [:group/pending?]))
|
||||
:req-un [:group/group-id :group/name :group/timestamp
|
||||
:group/order :group/contacts]
|
||||
:opt-un [:group/pending?]))
|
||||
|
||||
(spec/def :group/contact-groups (spec/nilable (spec/map-of :global/not-empty-string :group/contact-group)))
|
||||
;;used during editing contact group
|
||||
|
|
|
@ -8,45 +8,45 @@
|
|||
;;;; COFX
|
||||
|
||||
(re-frame/reg-cofx
|
||||
:get-default-contacts-and-groups
|
||||
(fn [coeffects _]
|
||||
(assoc coeffects
|
||||
:default-contacts js-res/default-contacts
|
||||
:default-groups js-res/default-contact-groups)))
|
||||
:get-default-contacts-and-groups
|
||||
(fn [coeffects _]
|
||||
(assoc coeffects
|
||||
:default-contacts js-res/default-contacts
|
||||
:default-groups js-res/default-contact-groups)))
|
||||
|
||||
;;;; Handlers
|
||||
|
||||
(handlers/register-handler-db
|
||||
:deselect-contact
|
||||
(fn [db [_ id]]
|
||||
(update db :group/selected-contacts disj id)))
|
||||
:deselect-contact
|
||||
(fn [db [_ id]]
|
||||
(update db :group/selected-contacts disj id)))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:select-contact
|
||||
(fn [db [_ id]]
|
||||
(update db :group/selected-contacts conj id)))
|
||||
:select-contact
|
||||
(fn [db [_ id]]
|
||||
(update db :group/selected-contacts conj id)))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:deselect-participant
|
||||
(fn [db [_ id]]
|
||||
(update db :selected-participants disj id)))
|
||||
:deselect-participant
|
||||
(fn [db [_ id]]
|
||||
(update db :selected-participants disj id)))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:select-participant
|
||||
(fn [db [_ id]]
|
||||
(update db :selected-participants conj id)))
|
||||
:select-participant
|
||||
(fn [db [_ id]]
|
||||
(update db :selected-participants conj id)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:create-new-contact-group
|
||||
[re-frame/trim-v (re-frame/inject-cofx :now) (re-frame/inject-cofx :random-id)]
|
||||
(fn [{{:group/keys [contact-groups selected-contacts] :as db} :db group-id :random-id now :now} [group-name]]
|
||||
(let [new-group {:group-id group-id
|
||||
:name group-name
|
||||
:order (count contact-groups)
|
||||
:timestamp now
|
||||
:contacts selected-contacts}]
|
||||
{:db (assoc-in db [:group/contact-groups group-id] new-group)
|
||||
:data-store/save-contact-group new-group})))
|
||||
:create-new-contact-group
|
||||
[re-frame/trim-v (re-frame/inject-cofx :now) (re-frame/inject-cofx :random-id)]
|
||||
(fn [{{:group/keys [contact-groups selected-contacts] :as db} :db group-id :random-id now :now} [group-name]]
|
||||
(let [new-group {:group-id group-id
|
||||
:name group-name
|
||||
:order (count contact-groups)
|
||||
:timestamp now
|
||||
:contacts selected-contacts}]
|
||||
{:db (assoc-in db [:group/contact-groups group-id] new-group)
|
||||
:data-store/save-contact-group new-group})))
|
||||
|
||||
(defn add-default-groups
|
||||
[{:keys [db now default-groups]}]
|
||||
|
@ -66,33 +66,33 @@
|
|||
:data-store/save-contact-groups (vals groups-to-add)}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:load-contact-groups
|
||||
[(re-frame/inject-cofx :data-store/get-all-contact-groups)]
|
||||
(fn [{:keys [db all-contact-groups]} _]
|
||||
{:db (assoc db :group/contact-groups all-contact-groups)}))
|
||||
:load-contact-groups
|
||||
[(re-frame/inject-cofx :data-store/get-all-contact-groups)]
|
||||
(fn [{:keys [db all-contact-groups]} _]
|
||||
{:db (assoc db :group/contact-groups all-contact-groups)}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:set-contact-group-name
|
||||
(fn [{{:keys [new-chat-name] :group/keys [contact-group-id] :as db} :db} _]
|
||||
{:db (assoc-in db
|
||||
[:group/contact-groups contact-group-id :name]
|
||||
new-chat-name)
|
||||
:data-store/save-contact-group-property [contact-group-id :name new-chat-name]}))
|
||||
:set-contact-group-name
|
||||
(fn [{{:keys [new-chat-name] :group/keys [contact-group-id] :as db} :db} _]
|
||||
{:db (assoc-in db
|
||||
[:group/contact-groups contact-group-id :name]
|
||||
new-chat-name)
|
||||
:data-store/save-contact-group-property [contact-group-id :name new-chat-name]}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:add-selected-contacts-to-group
|
||||
(fn [{{:group/keys [contact-groups contact-group-id selected-contacts] :as db} :db} _]
|
||||
{:db (update-in db
|
||||
[:group/contact-groups contact-group-id :contacts]
|
||||
#(into [] (set (concat % selected-contacts))))
|
||||
:data-store/add-contacts-to-contact-group [contact-group-id selected-contacts]}))
|
||||
:add-selected-contacts-to-group
|
||||
(fn [{{:group/keys [contact-groups contact-group-id selected-contacts] :as db} :db} _]
|
||||
{:db (update-in db
|
||||
[:group/contact-groups contact-group-id :contacts]
|
||||
#(into [] (set (concat % selected-contacts))))
|
||||
:data-store/add-contacts-to-contact-group [contact-group-id selected-contacts]}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:remove-contact-from-group
|
||||
[re-frame/trim-v]
|
||||
(fn [{:keys [db]} [whisper-identity group-id]]
|
||||
(let [group (-> db
|
||||
(get-in [:group/contact-groups group-id])
|
||||
(update :contacts (partial remove #(= whisper-identity %))))]
|
||||
{:db (assoc-in db [:group/contact-groups group-id] group)
|
||||
:data-store/save-contact-group group})))
|
||||
:remove-contact-from-group
|
||||
[re-frame/trim-v]
|
||||
(fn [{:keys [db]} [whisper-identity group-id]]
|
||||
(let [group (-> db
|
||||
(get-in [:group/contact-groups group-id])
|
||||
(update :contacts (partial remove #(= whisper-identity %))))]
|
||||
{:db (assoc-in db [:group/contact-groups group-id] group)
|
||||
:data-store/save-contact-group group})))
|
||||
|
|
|
@ -3,57 +3,57 @@
|
|||
[status-im.utils.subs :as utils]))
|
||||
|
||||
(reg-sub
|
||||
:is-contact-selected?
|
||||
(utils/contains-sub :group/selected-contacts))
|
||||
:is-contact-selected?
|
||||
(utils/contains-sub :group/selected-contacts))
|
||||
|
||||
(reg-sub
|
||||
:is-participant-selected?
|
||||
(utils/contains-sub :selected-participants))
|
||||
:is-participant-selected?
|
||||
(utils/contains-sub :selected-participants))
|
||||
|
||||
(defn filter-selected-contacts [selected-contacts contacts]
|
||||
(remove #(true? (:pending? (contacts %))) selected-contacts))
|
||||
|
||||
(reg-sub
|
||||
:selected-contacts-count
|
||||
:<- [:get :group/selected-contacts]
|
||||
:<- [:get-contacts]
|
||||
(fn [[selected-contacts contacts]]
|
||||
(count (filter-selected-contacts selected-contacts contacts))))
|
||||
:selected-contacts-count
|
||||
:<- [:get :group/selected-contacts]
|
||||
:<- [:get-contacts]
|
||||
(fn [[selected-contacts contacts]]
|
||||
(count (filter-selected-contacts selected-contacts contacts))))
|
||||
|
||||
(reg-sub
|
||||
:selected-participants-count
|
||||
:<- [:get :selected-participants]
|
||||
(fn [selected-participants]
|
||||
(count selected-participants)))
|
||||
:selected-participants-count
|
||||
:<- [:get :selected-participants]
|
||||
(fn [selected-participants]
|
||||
(count selected-participants)))
|
||||
|
||||
(defn filter-contacts [selected-contacts added-contacts]
|
||||
(filter #(selected-contacts (:whisper-identity %)) added-contacts))
|
||||
|
||||
(reg-sub
|
||||
:selected-group-contacts
|
||||
:<- [:get :group/selected-contacts]
|
||||
:<- [:all-added-contacts]
|
||||
(fn [[selected-contacts added-contacts]]
|
||||
(filter-contacts selected-contacts added-contacts)))
|
||||
:selected-group-contacts
|
||||
:<- [:get :group/selected-contacts]
|
||||
:<- [:all-added-contacts]
|
||||
(fn [[selected-contacts added-contacts]]
|
||||
(filter-contacts selected-contacts added-contacts)))
|
||||
|
||||
(reg-sub
|
||||
:get-contact-groups
|
||||
(fn [db]
|
||||
(:group/contact-groups db)))
|
||||
:get-contact-groups
|
||||
(fn [db]
|
||||
(:group/contact-groups db)))
|
||||
|
||||
(reg-sub
|
||||
:get-contact-group-id
|
||||
(fn [db]
|
||||
(:group/contact-group-id db)))
|
||||
:get-contact-group-id
|
||||
(fn [db]
|
||||
(:group/contact-group-id db)))
|
||||
|
||||
(reg-sub
|
||||
:get-contact-group
|
||||
:<- [:get-contact-groups]
|
||||
:<- [:get-contact-group-id]
|
||||
(fn [[groups group-id]]
|
||||
(get groups group-id)))
|
||||
:get-contact-group
|
||||
:<- [:get-contact-groups]
|
||||
:<- [:get-contact-group-id]
|
||||
(fn [[groups group-id]]
|
||||
(get groups group-id)))
|
||||
|
||||
(reg-sub
|
||||
:get-group-type
|
||||
(fn [db]
|
||||
(:group/group-type db)))
|
||||
:get-group-type
|
||||
(fn [db]
|
||||
(:group/group-type db)))
|
||||
|
|
|
@ -30,6 +30,5 @@
|
|||
:onPanResponderRelease (on-release animated-offset-x end-offset-x chat-id swiped?)
|
||||
:onPanResponderTerminate (on-release animated-offset-x end-offset-x chat-id swiped?)})))
|
||||
|
||||
|
||||
(defn pan-handlers [pan-responder]
|
||||
(js->clj (.-panHandlers pan-responder)))
|
|
@ -2,7 +2,7 @@
|
|||
(:require [re-frame.core :as re-frame]))
|
||||
|
||||
(re-frame/reg-sub :home-items
|
||||
:<- [:get-active-chats]
|
||||
:<- [:browsers]
|
||||
(fn [[chats browsers]]
|
||||
(sort-by #(-> % second :timestamp) > (merge chats browsers))))
|
||||
:<- [:get-active-chats]
|
||||
:<- [:browsers]
|
||||
(fn [[chats browsers]]
|
||||
(sort-by #(-> % second :timestamp) > (merge chats browsers))))
|
||||
|
|
|
@ -52,8 +52,8 @@
|
|||
(when is-deletable?
|
||||
[react/touchable-highlight {:style styles/delete-icon-highlight
|
||||
:on-press #(do
|
||||
(re-frame/dispatch [:set-swipe-position home-item-id false])
|
||||
(re-frame/dispatch [delete-action home-item-id]))}
|
||||
(re-frame/dispatch [:set-swipe-position home-item-id false])
|
||||
(re-frame/dispatch [delete-action home-item-id]))}
|
||||
[react/view {:style styles/delete-icon-container}
|
||||
[vector-icons/icon :icons/delete {:color colors/red}]]])]])))
|
||||
|
||||
|
|
|
@ -60,52 +60,52 @@
|
|||
;; event handlers
|
||||
|
||||
(handlers/register-handler-db
|
||||
:navigate-to
|
||||
(re-frame/enrich preload-data!)
|
||||
(fn [db [_ & params]]
|
||||
(apply navigate-to db params)))
|
||||
:navigate-to
|
||||
(re-frame/enrich preload-data!)
|
||||
(fn [db [_ & params]]
|
||||
(apply navigate-to db params)))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:navigate-to-modal
|
||||
(re-frame/enrich preload-data!)
|
||||
(fn [db [_ modal-view]]
|
||||
(assoc db :modal modal-view)))
|
||||
:navigate-to-modal
|
||||
(re-frame/enrich preload-data!)
|
||||
(fn [db [_ modal-view]]
|
||||
(assoc db :modal modal-view)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:navigation-replace
|
||||
(re-frame/enrich preload-data!)
|
||||
(fn [cofx [_ view-id]]
|
||||
(replace-view view-id cofx)))
|
||||
:navigation-replace
|
||||
(re-frame/enrich preload-data!)
|
||||
(fn [cofx [_ view-id]]
|
||||
(replace-view view-id cofx)))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:navigate-back
|
||||
(re-frame/enrich -preload-data!)
|
||||
(fn [{:keys [navigation-stack view-id modal] :as db} _]
|
||||
(cond
|
||||
modal (assoc db :modal nil
|
||||
:was-modal? true)
|
||||
(>= 1 (count navigation-stack)) db
|
||||
:navigate-back
|
||||
(re-frame/enrich -preload-data!)
|
||||
(fn [{:keys [navigation-stack view-id modal] :as db} _]
|
||||
(cond
|
||||
modal (assoc db :modal nil
|
||||
:was-modal? true)
|
||||
(>= 1 (count navigation-stack)) db
|
||||
|
||||
:else
|
||||
(let [[previous-view-id :as navigation-stack'] (pop navigation-stack)
|
||||
first-in-stack (first navigation-stack)]
|
||||
(if (= view-id first-in-stack)
|
||||
(-> db
|
||||
(assoc :view-id previous-view-id)
|
||||
(assoc :navigation-stack navigation-stack'))
|
||||
(assoc db :view-id first-in-stack))))))
|
||||
:else
|
||||
(let [[previous-view-id :as navigation-stack'] (pop navigation-stack)
|
||||
first-in-stack (first navigation-stack)]
|
||||
(if (= view-id first-in-stack)
|
||||
(-> db
|
||||
(assoc :view-id previous-view-id)
|
||||
(assoc :navigation-stack navigation-stack'))
|
||||
(assoc db :view-id first-in-stack))))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:navigate-to-clean
|
||||
(fn [cofx [_ view-id params]]
|
||||
(navigate-to-clean view-id cofx params)))
|
||||
:navigate-to-clean
|
||||
(fn [cofx [_ view-id params]]
|
||||
(navigate-to-clean view-id cofx params)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:navigate-to-tab
|
||||
(re-frame/enrich preload-data!)
|
||||
(fn [{:keys [db] :as cofx} [_ view-id]]
|
||||
(handlers-macro/merge-fx cofx
|
||||
{:db (-> db
|
||||
(assoc :prev-tab-view-id (:view-id db))
|
||||
(assoc :prev-view-id (:view-id db)))}
|
||||
(navigate-to-clean view-id))))
|
||||
:navigate-to-tab
|
||||
(re-frame/enrich preload-data!)
|
||||
(fn [{:keys [db] :as cofx} [_ view-id]]
|
||||
(handlers-macro/merge-fx cofx
|
||||
{:db (-> db
|
||||
(assoc :prev-tab-view-id (:view-id db))
|
||||
(assoc :prev-view-id (:view-id db)))}
|
||||
(navigate-to-clean view-id))))
|
||||
|
|
|
@ -10,46 +10,46 @@
|
|||
;; handlers
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:add-networks
|
||||
(fn [{{:networks/keys [networks] :as db} :db} [_ new-networks]]
|
||||
(let [identities (set (keys networks))
|
||||
new-networks' (->> new-networks
|
||||
(remove #(identities (:id %)))
|
||||
(map #(vector (:id %) %))
|
||||
(into {}))]
|
||||
{:db (-> db
|
||||
(update :networks merge new-networks')
|
||||
(assoc :new-networks (vals new-networks')))
|
||||
:save-networks new-networks'})))
|
||||
:add-networks
|
||||
(fn [{{:networks/keys [networks] :as db} :db} [_ new-networks]]
|
||||
(let [identities (set (keys networks))
|
||||
new-networks' (->> new-networks
|
||||
(remove #(identities (:id %)))
|
||||
(map #(vector (:id %) %))
|
||||
(into {}))]
|
||||
{:db (-> db
|
||||
(update :networks merge new-networks')
|
||||
(assoc :new-networks (vals new-networks')))
|
||||
:save-networks new-networks'})))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
::close-application
|
||||
(fn [_ _]
|
||||
{:close-application nil}))
|
||||
::close-application
|
||||
(fn [_ _]
|
||||
{:close-application nil}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
::save-network
|
||||
(fn [{:keys [db now] :as cofx} [_ network]]
|
||||
(handlers-macro/merge-fx cofx
|
||||
(accounts.utils/account-update {:network network
|
||||
:last-updated now}
|
||||
[::close-application]))))
|
||||
::save-network
|
||||
(fn [{:keys [db now] :as cofx} [_ network]]
|
||||
(handlers-macro/merge-fx cofx
|
||||
(accounts.utils/account-update {:network network
|
||||
:last-updated now}
|
||||
[::close-application]))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:connect-network
|
||||
(fn [{:keys [db now] :as cofx} [_ network]]
|
||||
(let [current-network (:network db)
|
||||
networks (:networks/networks db)
|
||||
chats (:transport/chats db)]
|
||||
(if (utils/network-with-upstream-rpc? networks current-network)
|
||||
(handlers-macro/merge-fx cofx
|
||||
{:dispatch-n [[:load-accounts]
|
||||
[:navigate-to-clean :accounts]]}
|
||||
(transport/stop-whisper)
|
||||
(accounts.utils/account-update {:network network
|
||||
:last-updated now}))
|
||||
{:show-confirmation {:title (i18n/label :t/close-app-title)
|
||||
:content (i18n/label :t/close-app-content)
|
||||
:confirm-button-text (i18n/label :t/close-app-button)
|
||||
:on-accept #(dispatch [::save-network network])
|
||||
:on-cancel nil}}))))
|
||||
:connect-network
|
||||
(fn [{:keys [db now] :as cofx} [_ network]]
|
||||
(let [current-network (:network db)
|
||||
networks (:networks/networks db)
|
||||
chats (:transport/chats db)]
|
||||
(if (utils/network-with-upstream-rpc? networks current-network)
|
||||
(handlers-macro/merge-fx cofx
|
||||
{:dispatch-n [[:load-accounts]
|
||||
[:navigate-to-clean :accounts]]}
|
||||
(transport/stop-whisper)
|
||||
(accounts.utils/account-update {:network network
|
||||
:last-updated now}))
|
||||
{:show-confirmation {:title (i18n/label :t/close-app-title)
|
||||
:content (i18n/label :t/close-app-content)
|
||||
:confirm-button-text (i18n/label :t/close-app-button)
|
||||
:on-accept #(dispatch [::save-network network])
|
||||
:on-cancel nil}}))))
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
(ns status-im.ui.screens.network-settings.network-details.views
|
||||
(:require-macros [status-im.utils.views :as views])
|
||||
(:require
|
||||
[re-frame.core :as rf]
|
||||
[status-im.ui.components.status-bar.view :as status-bar]
|
||||
[status-im.ui.components.toolbar.view :as toolbar]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.ui.screens.network-settings.styles :as st]
|
||||
[status-im.ui.screens.network-settings.views :as network-settings]))
|
||||
[re-frame.core :as rf]
|
||||
[status-im.ui.components.status-bar.view :as status-bar]
|
||||
[status-im.ui.components.toolbar.view :as toolbar]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.ui.screens.network-settings.styles :as st]
|
||||
[status-im.ui.screens.network-settings.views :as network-settings]))
|
||||
|
||||
(views/defview network-details []
|
||||
(views/letsubs [{:keys [networks/selected-network]} [:get-screen-params]
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
(:require [re-frame.core :refer [reg-sub subscribe]]))
|
||||
|
||||
(reg-sub
|
||||
:get-current-account-network
|
||||
:<- [:get-current-account]
|
||||
:<- [:get :networks/networks]
|
||||
(fn [[current-account networks]]
|
||||
(get networks (:network current-account))))
|
||||
:get-current-account-network
|
||||
:<- [:get-current-account]
|
||||
:<- [:get :networks/networks]
|
||||
(fn [[current-account networks]]
|
||||
(get networks (:network current-account))))
|
||||
|
||||
(reg-sub
|
||||
:get-network-id
|
||||
|
|
|
@ -8,21 +8,21 @@
|
|||
[status-im.utils.ethereum.core :as ethereum]))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
::save-wnode
|
||||
(fn [{:keys [db now] :as cofx} [_ wnode]]
|
||||
(let [network (ethereum/network->chain-keyword (:network db))
|
||||
settings (get-in db [:account/account :settings])]
|
||||
(handlers-macro/merge-fx cofx
|
||||
{:dispatch [:logout]}
|
||||
(accounts-events/update-settings (assoc-in settings [:wnode network] wnode))))))
|
||||
::save-wnode
|
||||
(fn [{:keys [db now] :as cofx} [_ wnode]]
|
||||
(let [network (ethereum/network->chain-keyword (:network db))
|
||||
settings (get-in db [:account/account :settings])]
|
||||
(handlers-macro/merge-fx cofx
|
||||
{:dispatch [:logout]}
|
||||
(accounts-events/update-settings (assoc-in settings [:wnode network] wnode))))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:connect-wnode
|
||||
(fn [{:keys [db]} [_ wnode]]
|
||||
(let [network (ethereum/network->chain-keyword (:network db))]
|
||||
{:show-confirmation {:title (i18n/label :t/close-app-title)
|
||||
:content (i18n/label :t/connect-wnode-content
|
||||
{:name (get-in db [:inbox/wnodes network wnode :name])})
|
||||
:confirm-button-text (i18n/label :t/close-app-button)
|
||||
:on-accept #(dispatch [::save-wnode wnode])
|
||||
:on-cancel nil}})))
|
||||
:connect-wnode
|
||||
(fn [{:keys [db]} [_ wnode]]
|
||||
(let [network (ethereum/network->chain-keyword (:network db))]
|
||||
{:show-confirmation {:title (i18n/label :t/close-app-title)
|
||||
:content (i18n/label :t/connect-wnode-content
|
||||
{:name (get-in db [:inbox/wnodes network wnode :name])})
|
||||
:confirm-button-text (i18n/label :t/close-app-button)
|
||||
:on-accept #(dispatch [::save-wnode wnode])
|
||||
:on-cancel nil}})))
|
||||
|
|
|
@ -3,15 +3,15 @@
|
|||
[status-im.utils.ethereum.core :as ethereum]))
|
||||
|
||||
(re-frame/reg-sub :settings/current-wnode
|
||||
:<- [:network]
|
||||
:<- [:get-current-account]
|
||||
(fn [[network current-account]]
|
||||
(let [chain (ethereum/network->chain-keyword network)]
|
||||
(get-in current-account [:settings :wnode chain]))))
|
||||
:<- [:network]
|
||||
:<- [:get-current-account]
|
||||
(fn [[network current-account]]
|
||||
(let [chain (ethereum/network->chain-keyword network)]
|
||||
(get-in current-account [:settings :wnode chain]))))
|
||||
|
||||
(re-frame/reg-sub :settings/network-wnodes
|
||||
:<- [:network]
|
||||
:<- [:get :inbox/wnodes]
|
||||
(fn [[network wnodes]]
|
||||
(let [chain (ethereum/network->chain-keyword network)]
|
||||
(chain wnodes))))
|
||||
:<- [:network]
|
||||
:<- [:get :inbox/wnodes]
|
||||
(fn [[network wnodes]]
|
||||
(let [chain (ethereum/network->chain-keyword network)]
|
||||
(chain wnodes))))
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
name]]])
|
||||
|
||||
(defn- profile-header-edit [{:keys [name group-chat] :as contact}
|
||||
icon-options on-change-text-event allow-icon-change?]
|
||||
icon-options on-change-text-event allow-icon-change?]
|
||||
[react/view styles/profile-header-edit
|
||||
[react/touchable-highlight {:on-press #(show-profile-icon-actions icon-options)
|
||||
:accessibility-label :edit-profile-photo-button}
|
||||
|
|
|
@ -13,27 +13,27 @@
|
|||
[taoensso.timbre :as log]))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:open-image-picker
|
||||
:open-image-picker
|
||||
;; the image picker is only used here for now, this effect can be use in other scenarios as well
|
||||
(fn [callback-event]
|
||||
(show-image-picker
|
||||
(fn [image]
|
||||
(let [path (get (js->clj image) "path")
|
||||
_ (log/debug path)
|
||||
on-success (fn [base64]
|
||||
(re-frame/dispatch [callback-event base64]))
|
||||
on-error (fn [type error]
|
||||
(.log js/console type error))]
|
||||
(img->base64 path on-success on-error))))))
|
||||
(fn [callback-event]
|
||||
(show-image-picker
|
||||
(fn [image]
|
||||
(let [path (get (js->clj image) "path")
|
||||
_ (log/debug path)
|
||||
on-success (fn [base64]
|
||||
(re-frame/dispatch [callback-event base64]))
|
||||
on-error (fn [type error]
|
||||
(.log js/console type error))]
|
||||
(img->base64 path on-success on-error))))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:profile/send-transaction
|
||||
[re-frame/trim-v]
|
||||
(fn [{{:contacts/keys [contacts]} :db :as cofx} [chat-id]]
|
||||
(let [send-command (get-in contacts chat-const/send-command-ref)]
|
||||
(handlers-macro/merge-fx cofx
|
||||
(chat-events/start-chat chat-id {:navigation-replace? true})
|
||||
(input-events/select-chat-input-command send-command nil true)))))
|
||||
:profile/send-transaction
|
||||
[re-frame/trim-v]
|
||||
(fn [{{:contacts/keys [contacts]} :db :as cofx} [chat-id]]
|
||||
(let [send-command (get-in contacts chat-const/send-command-ref)]
|
||||
(handlers-macro/merge-fx cofx
|
||||
(chat-events/start-chat chat-id {:navigation-replace? true})
|
||||
(input-events/select-chat-input-command send-command nil true)))))
|
||||
|
||||
(defn get-current-account [db]
|
||||
(:account/account db))
|
||||
|
@ -42,18 +42,18 @@
|
|||
(spec/valid? :profile/name name))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:my-profile/update-name
|
||||
(fn [{:keys [db]} [_ name]]
|
||||
{:db (-> db
|
||||
(assoc-in [:my-profile/profile :valid-name?] (valid-name? name))
|
||||
(assoc-in [:my-profile/profile :name] name))}))
|
||||
:my-profile/update-name
|
||||
(fn [{:keys [db]} [_ name]]
|
||||
{:db (-> db
|
||||
(assoc-in [:my-profile/profile :valid-name?] (valid-name? name))
|
||||
(assoc-in [:my-profile/profile :name] name))}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:my-profile/update-picture
|
||||
(fn [{:keys [db]} [this-event base64-image]]
|
||||
(if base64-image
|
||||
{:db (assoc-in db [:my-profile/profile :photo-path] (str "data:image/jpeg;base64," base64-image))}
|
||||
{:open-image-picker this-event})))
|
||||
:my-profile/update-picture
|
||||
(fn [{:keys [db]} [this-event base64-image]]
|
||||
(if base64-image
|
||||
{:db (assoc-in db [:my-profile/profile :photo-path] (str "data:image/jpeg;base64," base64-image))}
|
||||
{:open-image-picker this-event})))
|
||||
|
||||
(defn clean-name [db edit-view]
|
||||
(let [name (get-in db [edit-view :name])]
|
||||
|
@ -65,51 +65,51 @@
|
|||
{:db (dissoc db :my-profile/profile :my-profile/default-name :my-profile/editing?)})
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:my-profile/start-editing-profile
|
||||
(fn [{:keys [db]} []]
|
||||
{:db (assoc db :my-profile/editing? true)}))
|
||||
:my-profile/start-editing-profile
|
||||
(fn [{:keys [db]} []]
|
||||
{:db (assoc db :my-profile/editing? true)}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:my-profile/save-profile
|
||||
(fn [{:keys [db now] :as cofx} _]
|
||||
(let [{:keys [photo-path]} (:my-profile/profile db)
|
||||
cleaned-name (clean-name db :my-profile/profile)
|
||||
cleaned-edit (merge {:name cleaned-name
|
||||
:last-updated now}
|
||||
(if photo-path
|
||||
{:photo-path photo-path}))]
|
||||
(handlers-macro/merge-fx cofx
|
||||
(clear-profile)
|
||||
(accounts.utils/account-update cleaned-edit)))))
|
||||
:my-profile/save-profile
|
||||
(fn [{:keys [db now] :as cofx} _]
|
||||
(let [{:keys [photo-path]} (:my-profile/profile db)
|
||||
cleaned-name (clean-name db :my-profile/profile)
|
||||
cleaned-edit (merge {:name cleaned-name
|
||||
:last-updated now}
|
||||
(if photo-path
|
||||
{:photo-path photo-path}))]
|
||||
(handlers-macro/merge-fx cofx
|
||||
(clear-profile)
|
||||
(accounts.utils/account-update cleaned-edit)))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:group-chat-profile/start-editing
|
||||
(fn [{:keys [db]} _]
|
||||
{:db (assoc db :group-chat-profile/editing? true)}))
|
||||
:group-chat-profile/start-editing
|
||||
(fn [{:keys [db]} _]
|
||||
{:db (assoc db :group-chat-profile/editing? true)}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:group-chat-profile/save-profile
|
||||
(fn [{:keys [db]} _]
|
||||
(-> {:db db}
|
||||
(update :db dissoc :group-chat-profile/editing?))))
|
||||
:group-chat-profile/save-profile
|
||||
(fn [{:keys [db]} _]
|
||||
(-> {:db db}
|
||||
(update :db dissoc :group-chat-profile/editing?))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:my-profile/enter-two-random-words
|
||||
(fn [{:keys [db]} []]
|
||||
(let [{:keys [mnemonic]} (get-current-account db)
|
||||
shuffled-mnemonic (shuffle (map-indexed vector (clojure.string/split mnemonic #" ")))]
|
||||
{:db (assoc db :my-profile/seed {:step :first-word
|
||||
:first-word (first shuffled-mnemonic)
|
||||
:second-word (second shuffled-mnemonic)})})))
|
||||
:my-profile/enter-two-random-words
|
||||
(fn [{:keys [db]} []]
|
||||
(let [{:keys [mnemonic]} (get-current-account db)
|
||||
shuffled-mnemonic (shuffle (map-indexed vector (clojure.string/split mnemonic #" ")))]
|
||||
{:db (assoc db :my-profile/seed {:step :first-word
|
||||
:first-word (first shuffled-mnemonic)
|
||||
:second-word (second shuffled-mnemonic)})})))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:my-profile/set-step
|
||||
(fn [{:keys [db]} [_ step]]
|
||||
{:db (update db :my-profile/seed assoc :step step :error nil :word nil)}))
|
||||
:my-profile/set-step
|
||||
(fn [{:keys [db]} [_ step]]
|
||||
{:db (update db :my-profile/seed assoc :step step :error nil :word nil)}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:my-profile/finish
|
||||
(fn [{:keys [db] :as cofx} _]
|
||||
(handlers-macro/merge-fx cofx
|
||||
{:db (update db :my-profile/seed assoc :step :finish :error nil :word nil)}
|
||||
(accounts.utils/account-update {:seed-backed-up? true}))))
|
||||
:my-profile/finish
|
||||
(fn [{:keys [db] :as cofx} _]
|
||||
(handlers-macro/merge-fx cofx
|
||||
{:db (update db :my-profile/seed assoc :step :finish :error nil :word nil)}
|
||||
(accounts.utils/account-update {:seed-backed-up? true}))))
|
||||
|
|
|
@ -117,9 +117,9 @@
|
|||
|
||||
:else
|
||||
(utils/show-question
|
||||
(i18n/label :t/are-you-sure?)
|
||||
(i18n/label :t/are-you-sure-description)
|
||||
#(re-frame/dispatch [:my-profile/finish]))))}]]])
|
||||
(i18n/label :t/are-you-sure?)
|
||||
(i18n/label :t/are-you-sure-description)
|
||||
#(re-frame/dispatch [:my-profile/finish]))))}]]])
|
||||
|
||||
(defn finish []
|
||||
[react/view {:style styles/finish-container}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
[clojure.string :as string]))
|
||||
|
||||
(reg-sub
|
||||
:get-profile-unread-messages-number
|
||||
:<- [:get-current-account]
|
||||
(fn [{:keys [seed-backed-up? mnemonic]}]
|
||||
(if (or seed-backed-up? (string/blank? mnemonic)) 0 1)))
|
||||
:get-profile-unread-messages-number
|
||||
:<- [:get-current-account]
|
||||
(fn [{:keys [seed-backed-up? mnemonic]}]
|
||||
(if (or seed-backed-up? (string/blank? mnemonic)) 0 1)))
|
|
@ -92,8 +92,8 @@
|
|||
(utils/show-confirmation (i18n/label :t/logout-title)
|
||||
(i18n/label :t/logout-are-you-sure)
|
||||
(i18n/label :t/logout) #(keychain/get-encryption-key-then
|
||||
(fn [encryption-key]
|
||||
(re-frame/dispatch [:logout encryption-key])))))
|
||||
(fn [encryption-key]
|
||||
(re-frame/dispatch [:logout encryption-key])))))
|
||||
|
||||
(defn- my-profile-settings [{:keys [seed-backed-up? mnemonic]} sharing-usage-data?]
|
||||
(let [show-backup-seed? (and (not seed-backed-up?) (not (string/blank? mnemonic)))]
|
||||
|
@ -115,14 +115,14 @@
|
|||
:icon-content [components.common/counter {:size 22} 1]}])
|
||||
[profile.components/settings-item-separator]
|
||||
[react/view styles/my-profile-settings-logout-wrapper
|
||||
[react/view styles/my-profile-settings-logout
|
||||
[profile.components/settings-item {:label-kw :t/logout
|
||||
:accessibility-label :log-out-button
|
||||
:destructive? true
|
||||
:hide-arrow? true
|
||||
:action-fn #(handle-logout)}]]
|
||||
[react/view styles/my-profile-settings-logout-version
|
||||
[react/text build/version]]]]))
|
||||
[react/view styles/my-profile-settings-logout
|
||||
[profile.components/settings-item {:label-kw :t/logout
|
||||
:accessibility-label :log-out-button
|
||||
:destructive? true
|
||||
:hide-arrow? true
|
||||
:action-fn #(handle-logout)}]]
|
||||
[react/view styles/my-profile-settings-logout-version
|
||||
[react/text build/version]]]]))
|
||||
|
||||
(defview advanced [{:keys [network networks dev-mode?]}]
|
||||
(letsubs [advanced? [:get :my-profile/advanced?]
|
||||
|
|
|
@ -6,24 +6,24 @@
|
|||
[status-im.i18n :as i18n]))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:scan-qr-code
|
||||
(fn [{:keys [db]} [_ identifier handler]]
|
||||
{:db (assoc-in db [:qr-codes identifier] handler)
|
||||
:request-permissions-fx {:permissions [:camera]
|
||||
:on-allowed #(re-frame/dispatch [:navigate-to :qr-scanner {:current-qr-context identifier}])
|
||||
:on-denied #(utils/show-popup (i18n/label :t/error)
|
||||
(i18n/label :t/camera-access-error))}}))
|
||||
:scan-qr-code
|
||||
(fn [{:keys [db]} [_ identifier handler]]
|
||||
{:db (assoc-in db [:qr-codes identifier] handler)
|
||||
:request-permissions-fx {:permissions [:camera]
|
||||
:on-allowed #(re-frame/dispatch [:navigate-to :qr-scanner {:current-qr-context identifier}])
|
||||
:on-denied #(utils/show-popup (i18n/label :t/error)
|
||||
(i18n/label :t/camera-access-error))}}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:clear-qr-code
|
||||
(fn [{:keys [db]} [_ identifier]]
|
||||
{:db (update db :qr-codes dissoc identifier)}))
|
||||
:clear-qr-code
|
||||
(fn [{:keys [db]} [_ identifier]]
|
||||
{:db (update db :qr-codes dissoc identifier)}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:set-qr-code
|
||||
(fn [{:keys [db]} [_ context data]]
|
||||
(merge {:db (-> db
|
||||
(update :qr-codes dissoc context)
|
||||
(dissoc :current-qr-context))}
|
||||
(when-let [handler (get-in db [:qr-codes context])]
|
||||
{:dispatch [handler context data]}))))
|
||||
:set-qr-code
|
||||
(fn [{:keys [db]} [_ context data]]
|
||||
(merge {:db (-> db
|
||||
(update :qr-codes dissoc context)
|
||||
(dissoc :current-qr-context))}
|
||||
(when-let [handler (get-in db [:qr-codes context])]
|
||||
{:dispatch [handler context data]}))))
|
||||
|
|
|
@ -19,17 +19,17 @@
|
|||
status-im.ui.screens.profile.subs))
|
||||
|
||||
(reg-sub :get
|
||||
(fn [db [_ k]]
|
||||
(get db k)))
|
||||
(fn [db [_ k]]
|
||||
(get db k)))
|
||||
|
||||
(reg-sub :get-in
|
||||
(fn [db [_ path]]
|
||||
(get-in db path)))
|
||||
(fn [db [_ path]]
|
||||
(get-in db path)))
|
||||
|
||||
(reg-sub :signed-up?
|
||||
:<- [:get-current-account]
|
||||
(fn [current-account]
|
||||
(:signed-up? current-account)))
|
||||
:<- [:get-current-account]
|
||||
(fn [current-account]
|
||||
(:signed-up? current-account)))
|
||||
|
||||
(reg-sub :network :network)
|
||||
|
||||
|
@ -39,37 +39,37 @@
|
|||
(reg-sub :mailserver-status :mailserver-status)
|
||||
|
||||
(reg-sub :offline?
|
||||
:<- [:network-status]
|
||||
:<- [:sync-state]
|
||||
(fn [[network-status sync-state]]
|
||||
(or (= network-status :offline)
|
||||
(= sync-state :offline))))
|
||||
:<- [:network-status]
|
||||
:<- [:sync-state]
|
||||
(fn [[network-status sync-state]]
|
||||
(or (= network-status :offline)
|
||||
(= sync-state :offline))))
|
||||
|
||||
(reg-sub :connection-problem?
|
||||
:<- [:mailserver-status]
|
||||
:<- [:peers-count]
|
||||
(fn [[mailserver-status peers-count]]
|
||||
(or (= :disconnected mailserver-status)
|
||||
(zero? peers-count))))
|
||||
:<- [:mailserver-status]
|
||||
:<- [:peers-count]
|
||||
(fn [[mailserver-status peers-count]]
|
||||
(or (= :disconnected mailserver-status)
|
||||
(zero? peers-count))))
|
||||
|
||||
(reg-sub :syncing?
|
||||
:<- [:sync-state]
|
||||
(fn [sync-state]
|
||||
(#{:pending :in-progress} sync-state)))
|
||||
:<- [:sync-state]
|
||||
(fn [sync-state]
|
||||
(#{:pending :in-progress} sync-state)))
|
||||
|
||||
(reg-sub :tab-bar-visible?
|
||||
(fn [db _]
|
||||
(get db :tab-bar-visible?)))
|
||||
(fn [db _]
|
||||
(get db :tab-bar-visible?)))
|
||||
|
||||
(reg-sub :get-screen-params
|
||||
(fn [db [_ view-id]]
|
||||
(get-in db [:navigation/screen-params (or view-id (:view-id db))])))
|
||||
(fn [db [_ view-id]]
|
||||
(get-in db [:navigation/screen-params (or view-id (:view-id db))])))
|
||||
|
||||
(reg-sub :can-navigate-back?
|
||||
(fn [db]
|
||||
(> (count (:navigation-stack db)) 1)))
|
||||
(fn [db]
|
||||
(> (count (:navigation-stack db)) 1)))
|
||||
|
||||
(reg-sub :delete-swipe-position
|
||||
(fn [db [_ item-id]]
|
||||
(let [item-animation (get-in db [:chat-animations item-id])]
|
||||
(if (some? item-animation) (:delete-swiped item-animation) nil))))
|
||||
(fn [db [_ item-id]]
|
||||
(let [item-animation (get-in db [:chat-animations item-id])]
|
||||
(if (some? item-animation) (:delete-swiped item-animation) nil))))
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
[status-im.ui.screens.accounts.utils :as accounts.utils]))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:help-improve-handler
|
||||
(fn [{db :db} [_ yes? next]]
|
||||
(merge (accounts.utils/account-update {:sharing-usage-data? yes?} {:db db})
|
||||
{:dispatch (or next [:navigate-to-clean :home])})))
|
||||
:help-improve-handler
|
||||
(fn [{db :db} [_ yes? next]]
|
||||
(merge (accounts.utils/account-update {:sharing-usage-data? yes?} {:db db})
|
||||
{:dispatch (or next [:navigate-to-clean :home])})))
|
||||
|
|
|
@ -75,42 +75,42 @@
|
|||
;;; |
|
||||
;;; - profile-photo-capture
|
||||
(views/compile-views root-view
|
||||
[{:views #{:home :wallet :my-profile}
|
||||
:component main-tabs}
|
||||
[{:views #{:home :wallet :my-profile}
|
||||
:component main-tabs}
|
||||
|
||||
{:view :chat
|
||||
:hide? (not android?)
|
||||
:component chat}
|
||||
{:view :chat
|
||||
:hide? (not android?)
|
||||
:component chat}
|
||||
|
||||
{:view :wallet-send-transaction
|
||||
:parent :wallet
|
||||
:hide? (not android?)
|
||||
:component send-transaction}
|
||||
{:view :wallet-send-transaction
|
||||
:parent :wallet
|
||||
:hide? (not android?)
|
||||
:component send-transaction}
|
||||
|
||||
{:view :wallet-request-transaction
|
||||
:parent :wallet
|
||||
:component request-transaction}
|
||||
{:view :wallet-request-transaction
|
||||
:parent :wallet
|
||||
:component request-transaction}
|
||||
|
||||
{:view :wallet-request-assets
|
||||
:parent :wallet-request-transaction
|
||||
:component wallet.components/request-assets}
|
||||
{:view :wallet-request-assets
|
||||
:parent :wallet-request-transaction
|
||||
:component wallet.components/request-assets}
|
||||
|
||||
{:view :choose-recipient
|
||||
:parent :wallet-send-transaction
|
||||
:hide? true
|
||||
:component choose-recipient}
|
||||
{:view :choose-recipient
|
||||
:parent :wallet-send-transaction
|
||||
:hide? true
|
||||
:component choose-recipient}
|
||||
|
||||
{:view :wallet-transaction-sent
|
||||
:parent :wallet-send-transaction
|
||||
:component transaction-sent}
|
||||
{:view :wallet-transaction-sent
|
||||
:parent :wallet-send-transaction
|
||||
:component transaction-sent}
|
||||
|
||||
{:views #{:transactions-history :unsigned-transactions}
|
||||
:parent :wallet
|
||||
:component wallet-transactions/transactions}
|
||||
{:views #{:transactions-history :unsigned-transactions}
|
||||
:parent :wallet
|
||||
:component wallet-transactions/transactions}
|
||||
|
||||
{:view :profile-photo-capture
|
||||
:parent :my-profile
|
||||
:component profile-photo-capture}])
|
||||
{:view :profile-photo-capture
|
||||
:parent :my-profile
|
||||
:component profile-photo-capture}])
|
||||
|
||||
(defview main []
|
||||
(letsubs [signed-up? [:signed-up?]
|
||||
|
@ -167,7 +167,7 @@
|
|||
:choose-recipient :wallet-transaction-sent :transactions-history
|
||||
:unsigned-transactions :wallet-request-transaction :edit-my-profile
|
||||
:profile-photo-capture :wallet-request-assets}
|
||||
view-id))
|
||||
view-id))
|
||||
[root-view]
|
||||
[component])
|
||||
(when modal-view
|
||||
|
@ -186,4 +186,4 @@
|
|||
:wallet-transaction-fee wallet.send/transaction-fee
|
||||
[react/view [react/text (str "Unknown modal view: " modal-view)]])]
|
||||
[react/main-screen-modal-view modal-view
|
||||
[component]])]])]))))
|
||||
[component]])]])]))))
|
||||
|
|
|
@ -7,23 +7,23 @@
|
|||
[status-im.utils.money :as money]))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:wallet/toggle-flashlight
|
||||
(fn [db]
|
||||
(let [flashlight-state (get-in db [:wallet :send-transaction :camera-flashlight])
|
||||
toggled-state (if (= :on flashlight-state) :off :on)]
|
||||
(assoc-in db [:wallet :send-transaction :camera-flashlight] toggled-state))))
|
||||
:wallet/toggle-flashlight
|
||||
(fn [db]
|
||||
(let [flashlight-state (get-in db [:wallet :send-transaction :camera-flashlight])
|
||||
toggled-state (if (= :on flashlight-state) :off :on)]
|
||||
(assoc-in db [:wallet :send-transaction :camera-flashlight] toggled-state))))
|
||||
|
||||
(defn- fill-request-details [db {:keys [address name value symbol gas gasPrice whisper-identity]}]
|
||||
{:pre [(not (nil? address))]}
|
||||
(update-in
|
||||
db [:wallet :send-transaction]
|
||||
#(cond-> (assoc % :to address :to-name name :whisper-identity whisper-identity)
|
||||
value (assoc :amount value)
|
||||
symbol (assoc :symbol symbol)
|
||||
gas (assoc :gas (money/bignumber gas))
|
||||
gasPrice (assoc :gas-price (money/bignumber gasPrice))
|
||||
(and symbol (not gasPrice))
|
||||
(assoc :gas-price (ethereum/estimate-gas symbol)))))
|
||||
db [:wallet :send-transaction]
|
||||
#(cond-> (assoc % :to address :to-name name :whisper-identity whisper-identity)
|
||||
value (assoc :amount value)
|
||||
symbol (assoc :symbol symbol)
|
||||
gas (assoc :gas (money/bignumber gas))
|
||||
gasPrice (assoc :gas-price (money/bignumber gasPrice))
|
||||
(and symbol (not gasPrice))
|
||||
(assoc :gas-price (ethereum/estimate-gas symbol)))))
|
||||
|
||||
(defn- extract-details
|
||||
"First try to parse as EIP681 URI, if not assume this is an address directly.
|
||||
|
@ -35,21 +35,21 @@
|
|||
{:address s :chain-id chain-id})))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet/fill-request-from-url
|
||||
(fn [{{:keys [network] :as db} :db} [_ data]]
|
||||
(let [{:keys [view-id]} db
|
||||
current-chain-id (get-in constants/default-networks [network :raw-config :NetworkId])
|
||||
{:keys [address chain-id] :as details} (extract-details data current-chain-id)
|
||||
valid-network? (boolean (= current-chain-id chain-id))]
|
||||
(cond-> {:db db
|
||||
:dispatch [:navigate-back]}
|
||||
(and address (= :choose-recipient view-id)) (assoc :dispatch [:navigate-back])
|
||||
(and address valid-network?) (update :db #(fill-request-details % details))
|
||||
(not address) (assoc :show-error (i18n/label :t/wallet-invalid-address {:data data}))
|
||||
(and address (not valid-network?)) (assoc :show-error (i18n/label :t/wallet-invalid-chain-id {:data data :chain current-chain-id}))))))
|
||||
:wallet/fill-request-from-url
|
||||
(fn [{{:keys [network] :as db} :db} [_ data]]
|
||||
(let [{:keys [view-id]} db
|
||||
current-chain-id (get-in constants/default-networks [network :raw-config :NetworkId])
|
||||
{:keys [address chain-id] :as details} (extract-details data current-chain-id)
|
||||
valid-network? (boolean (= current-chain-id chain-id))]
|
||||
(cond-> {:db db
|
||||
:dispatch [:navigate-back]}
|
||||
(and address (= :choose-recipient view-id)) (assoc :dispatch [:navigate-back])
|
||||
(and address valid-network?) (update :db #(fill-request-details % details))
|
||||
(not address) (assoc :show-error (i18n/label :t/wallet-invalid-address {:data data}))
|
||||
(and address (not valid-network?)) (assoc :show-error (i18n/label :t/wallet-invalid-chain-id {:data data :chain current-chain-id}))))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet/fill-request-from-contact
|
||||
(fn [{db :db} [_ {:keys [address name whisper-identity]}]]
|
||||
{:db (fill-request-details db {:address address :name name :whisper-identity whisper-identity})
|
||||
:dispatch [:navigate-back]}))
|
||||
:wallet/fill-request-from-contact
|
||||
(fn [{db :db} [_ {:keys [address name whisper-identity]}]]
|
||||
{:db (fill-request-details db {:address address :name name :whisper-identity whisper-identity})
|
||||
:dispatch [:navigate-back]}))
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
(defn- viewfinder [{:keys [height width]} size]
|
||||
(let [height (cond-> height
|
||||
platform/iphone-x? (- 78))]
|
||||
platform/iphone-x? (- 78))]
|
||||
[react/view {:style styles/viewfinder-port}
|
||||
[react/view {:style (styles/viewfinder-translucent height width size :top)}]
|
||||
[react/view {:style (styles/viewfinder-translucent height width size :right)}]
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
|
||||
(def text-input
|
||||
(merge text-content
|
||||
{:font-size 15
|
||||
:flex 1
|
||||
:padding-bottom 0
|
||||
:padding-top 0
|
||||
:height 52
|
||||
:letter-spacing -0.2}))
|
||||
{:font-size 15
|
||||
:flex 1
|
||||
:padding-bottom 0
|
||||
:padding-top 0
|
||||
:height 52
|
||||
:letter-spacing -0.2}))
|
||||
|
||||
(def contact-code-text-input
|
||||
{:text-align-vertical :top
|
||||
|
@ -185,4 +185,3 @@
|
|||
:font-size 15
|
||||
:letter-spacing -0.2})
|
||||
|
||||
|
||||
|
|
|
@ -162,13 +162,13 @@
|
|||
(defn- on-choose-recipient [contact-only?]
|
||||
(list-selection/show {:title (i18n/label :t/wallet-choose-recipient)
|
||||
:options (concat
|
||||
[{:label (i18n/label :t/recent-recipients)
|
||||
:action #(re-frame/dispatch [:navigate-to :recent-recipients])}]
|
||||
(when-not contact-only?
|
||||
[{:label (i18n/label :t/scan-qr)
|
||||
:action request-camera-permissions}
|
||||
{:label (i18n/label :t/recipient-code)
|
||||
:action #(re-frame/dispatch [:navigate-to :contact-code])}]))}))
|
||||
[{:label (i18n/label :t/recent-recipients)
|
||||
:action #(re-frame/dispatch [:navigate-to :recent-recipients])}]
|
||||
(when-not contact-only?
|
||||
[{:label (i18n/label :t/scan-qr)
|
||||
:action request-camera-permissions}
|
||||
{:label (i18n/label :t/recipient-code)
|
||||
:action #(re-frame/dispatch [:navigate-to :contact-code])}]))}))
|
||||
|
||||
(defn recipient-selector [{:keys [name address disabled? contact-only? request?]}]
|
||||
[components/cartouche {:on-press #(on-choose-recipient contact-only?)
|
||||
|
@ -186,13 +186,13 @@
|
|||
:accessibility-label :specify-amount-button}
|
||||
[components/text-input
|
||||
(merge
|
||||
(if disabled?
|
||||
{:editable false}
|
||||
{:keyboard-type :numeric
|
||||
:placeholder (i18n/label :t/amount-placeholder)
|
||||
:style components.styles/flex
|
||||
:accessibility-label :amount-input})
|
||||
input-options)]])
|
||||
(if disabled?
|
||||
{:editable false}
|
||||
{:keyboard-type :numeric
|
||||
:placeholder (i18n/label :t/amount-placeholder)
|
||||
:style components.styles/flex
|
||||
:accessibility-label :amount-input})
|
||||
input-options)]])
|
||||
|
||||
(defn amount-selector [{:keys [error disabled?] :as m}]
|
||||
[react/view
|
||||
|
|
|
@ -26,13 +26,13 @@
|
|||
(defn get-token-balance [{:keys [web3 contract account-id on-success on-error]}]
|
||||
(if (and web3 contract account-id)
|
||||
(erc20/balance-of
|
||||
web3
|
||||
contract
|
||||
(ethereum/normalized-address account-id)
|
||||
(fn [err resp]
|
||||
(if-not err
|
||||
(on-success resp)
|
||||
(on-error err))))
|
||||
web3
|
||||
contract
|
||||
(ethereum/normalized-address account-id)
|
||||
(fn [err resp]
|
||||
(if-not err
|
||||
(on-success resp)
|
||||
(on-error err))))
|
||||
(on-error "web3, contract or account-id not available")))
|
||||
|
||||
(defn assoc-error-message [db error-type err]
|
||||
|
@ -45,203 +45,203 @@
|
|||
;; FX
|
||||
|
||||
(reg-fx
|
||||
:get-balance
|
||||
(fn [{:keys [web3 account-id success-event error-event]}]
|
||||
(get-balance {:web3 web3
|
||||
:account-id account-id
|
||||
:on-success #(re-frame/dispatch [success-event %])
|
||||
:on-error #(re-frame/dispatch [error-event %])})))
|
||||
:get-balance
|
||||
(fn [{:keys [web3 account-id success-event error-event]}]
|
||||
(get-balance {:web3 web3
|
||||
:account-id account-id
|
||||
:on-success #(re-frame/dispatch [success-event %])
|
||||
:on-error #(re-frame/dispatch [error-event %])})))
|
||||
|
||||
(reg-fx
|
||||
:get-tokens-balance
|
||||
(fn [{:keys [web3 symbols chain account-id success-event error-event]}]
|
||||
(doseq [symbol symbols]
|
||||
(let [contract (:address (tokens/symbol->token chain symbol))]
|
||||
(get-token-balance {:web3 web3
|
||||
:contract contract
|
||||
:account-id account-id
|
||||
:on-success #(re-frame/dispatch [success-event symbol %])
|
||||
:on-error #(re-frame/dispatch [error-event %])})))))
|
||||
:get-tokens-balance
|
||||
(fn [{:keys [web3 symbols chain account-id success-event error-event]}]
|
||||
(doseq [symbol symbols]
|
||||
(let [contract (:address (tokens/symbol->token chain symbol))]
|
||||
(get-token-balance {:web3 web3
|
||||
:contract contract
|
||||
:account-id account-id
|
||||
:on-success #(re-frame/dispatch [success-event symbol %])
|
||||
:on-error #(re-frame/dispatch [error-event %])})))))
|
||||
|
||||
(reg-fx
|
||||
:get-transactions
|
||||
(fn [{:keys [network account-id success-event error-event]}]
|
||||
(transactions/get-transactions network
|
||||
account-id
|
||||
#(re-frame/dispatch [success-event %])
|
||||
#(re-frame/dispatch [error-event %]))))
|
||||
:get-transactions
|
||||
(fn [{:keys [network account-id success-event error-event]}]
|
||||
(transactions/get-transactions network
|
||||
account-id
|
||||
#(re-frame/dispatch [success-event %])
|
||||
#(re-frame/dispatch [error-event %]))))
|
||||
|
||||
;; TODO(oskarth): At some point we want to get list of relevant assets to get prices for
|
||||
(reg-fx
|
||||
:get-prices
|
||||
(fn [{:keys [from to success-event error-event]}]
|
||||
(prices/get-prices from
|
||||
to
|
||||
#(re-frame/dispatch [success-event %])
|
||||
#(re-frame/dispatch [error-event %]))))
|
||||
:get-prices
|
||||
(fn [{:keys [from to success-event error-event]}]
|
||||
(prices/get-prices from
|
||||
to
|
||||
#(re-frame/dispatch [success-event %])
|
||||
#(re-frame/dispatch [error-event %]))))
|
||||
|
||||
(reg-fx
|
||||
:update-gas-price
|
||||
(fn [{:keys [web3 success-event edit?]}]
|
||||
(ethereum/gas-price web3 #(re-frame/dispatch [success-event %2 edit?]))))
|
||||
:update-gas-price
|
||||
(fn [{:keys [web3 success-event edit?]}]
|
||||
(ethereum/gas-price web3 #(re-frame/dispatch [success-event %2 edit?]))))
|
||||
|
||||
(reg-fx
|
||||
:update-estimated-gas
|
||||
(fn [{:keys [web3 obj success-event]}]
|
||||
(ethereum/estimate-gas-web3 web3 (clj->js obj) #(re-frame/dispatch [success-event %2]))))
|
||||
:update-estimated-gas
|
||||
(fn [{:keys [web3 obj success-event]}]
|
||||
(ethereum/estimate-gas-web3 web3 (clj->js obj) #(re-frame/dispatch [success-event %2]))))
|
||||
|
||||
;; Handlers
|
||||
(handlers/register-handler-fx
|
||||
:update-wallet
|
||||
(fn [{{:keys [web3 account/account network network-status] :as db} :db} _]
|
||||
(let [chain (ethereum/network->chain-keyword network)
|
||||
mainnet? (= :mainnet chain)
|
||||
address (:address account)
|
||||
symbols (get-in account [:settings :wallet :visible-tokens chain])]
|
||||
(when (not= network-status :offline)
|
||||
{:get-balance {:web3 web3
|
||||
:account-id address
|
||||
:success-event :update-balance-success
|
||||
:error-event :update-balance-fail}
|
||||
:get-tokens-balance {:web3 web3
|
||||
:account-id address
|
||||
:symbols symbols
|
||||
:chain chain
|
||||
:success-event :update-token-balance-success
|
||||
:error-event :update-token-balance-fail}
|
||||
:get-prices {:from (if mainnet? (conj symbols "ETH") ["ETH"])
|
||||
:to ["USD"]
|
||||
:success-event :update-prices-success
|
||||
:error-event :update-prices-fail}
|
||||
:db (-> db
|
||||
(clear-error-message :prices-update)
|
||||
(clear-error-message :balance-update)
|
||||
(assoc-in [:wallet :balance-loading?] true)
|
||||
(assoc :prices-loading? true))}))))
|
||||
:update-wallet
|
||||
(fn [{{:keys [web3 account/account network network-status] :as db} :db} _]
|
||||
(let [chain (ethereum/network->chain-keyword network)
|
||||
mainnet? (= :mainnet chain)
|
||||
address (:address account)
|
||||
symbols (get-in account [:settings :wallet :visible-tokens chain])]
|
||||
(when (not= network-status :offline)
|
||||
{:get-balance {:web3 web3
|
||||
:account-id address
|
||||
:success-event :update-balance-success
|
||||
:error-event :update-balance-fail}
|
||||
:get-tokens-balance {:web3 web3
|
||||
:account-id address
|
||||
:symbols symbols
|
||||
:chain chain
|
||||
:success-event :update-token-balance-success
|
||||
:error-event :update-token-balance-fail}
|
||||
:get-prices {:from (if mainnet? (conj symbols "ETH") ["ETH"])
|
||||
:to ["USD"]
|
||||
:success-event :update-prices-success
|
||||
:error-event :update-prices-fail}
|
||||
:db (-> db
|
||||
(clear-error-message :prices-update)
|
||||
(clear-error-message :balance-update)
|
||||
(assoc-in [:wallet :balance-loading?] true)
|
||||
(assoc :prices-loading? true))}))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:update-transactions
|
||||
(fn [{{:keys [network network-status] :as db} :db} _]
|
||||
(when (not= network-status :offline)
|
||||
{:get-transactions {:account-id (get-in db [:account/account :address])
|
||||
:network network
|
||||
:success-event :update-transactions-success
|
||||
:error-event :update-transactions-fail}
|
||||
:db (-> db
|
||||
(clear-error-message :transactions-update)
|
||||
(assoc-in [:wallet :transactions-loading?] true))})))
|
||||
:update-transactions
|
||||
(fn [{{:keys [network network-status] :as db} :db} _]
|
||||
(when (not= network-status :offline)
|
||||
{:get-transactions {:account-id (get-in db [:account/account :address])
|
||||
:network network
|
||||
:success-event :update-transactions-success
|
||||
:error-event :update-transactions-fail}
|
||||
:db (-> db
|
||||
(clear-error-message :transactions-update)
|
||||
(assoc-in [:wallet :transactions-loading?] true))})))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:update-transactions-success
|
||||
(fn [db [_ transactions]]
|
||||
(-> db
|
||||
(update-in [:wallet :transactions] merge transactions)
|
||||
(assoc-in [:wallet :transactions-loading?] false))))
|
||||
:update-transactions-success
|
||||
(fn [db [_ transactions]]
|
||||
(-> db
|
||||
(update-in [:wallet :transactions] merge transactions)
|
||||
(assoc-in [:wallet :transactions-loading?] false))))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:update-transactions-fail
|
||||
(fn [db [_ err]]
|
||||
(log/debug "Unable to get transactions: " err)
|
||||
(-> db
|
||||
(assoc-error-message :transactions-update err)
|
||||
(assoc-in [:wallet :transactions-loading?] false))))
|
||||
:update-transactions-fail
|
||||
(fn [db [_ err]]
|
||||
(log/debug "Unable to get transactions: " err)
|
||||
(-> db
|
||||
(assoc-error-message :transactions-update err)
|
||||
(assoc-in [:wallet :transactions-loading?] false))))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:update-balance-success
|
||||
(fn [db [_ balance]]
|
||||
(-> db
|
||||
(assoc-in [:wallet :balance :ETH] balance)
|
||||
(assoc-in [:wallet :balance-loading?] false))))
|
||||
:update-balance-success
|
||||
(fn [db [_ balance]]
|
||||
(-> db
|
||||
(assoc-in [:wallet :balance :ETH] balance)
|
||||
(assoc-in [:wallet :balance-loading?] false))))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:update-balance-fail
|
||||
(fn [db [_ err]]
|
||||
(log/debug "Unable to get balance: " err)
|
||||
(-> db
|
||||
(assoc-error-message :balance-update err)
|
||||
(assoc-in [:wallet :balance-loading?] false))))
|
||||
:update-balance-fail
|
||||
(fn [db [_ err]]
|
||||
(log/debug "Unable to get balance: " err)
|
||||
(-> db
|
||||
(assoc-error-message :balance-update err)
|
||||
(assoc-in [:wallet :balance-loading?] false))))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:update-token-balance-success
|
||||
(fn [db [_ symbol balance]]
|
||||
(-> db
|
||||
(assoc-in [:wallet :balance symbol] balance)
|
||||
(assoc-in [:wallet :balance-loading?] false))))
|
||||
:update-token-balance-success
|
||||
(fn [db [_ symbol balance]]
|
||||
(-> db
|
||||
(assoc-in [:wallet :balance symbol] balance)
|
||||
(assoc-in [:wallet :balance-loading?] false))))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:update-token-balance-fail
|
||||
(fn [db [_ err]]
|
||||
(log/debug "Unable to get token balance: " err)
|
||||
(-> db
|
||||
(assoc-error-message :balance-update err)
|
||||
(assoc-in [:wallet :balance-loading?] false))))
|
||||
:update-token-balance-fail
|
||||
(fn [db [_ err]]
|
||||
(log/debug "Unable to get token balance: " err)
|
||||
(-> db
|
||||
(assoc-error-message :balance-update err)
|
||||
(assoc-in [:wallet :balance-loading?] false))))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:update-prices-success
|
||||
(fn [db [_ prices]]
|
||||
(assoc db
|
||||
:prices prices
|
||||
:prices-loading? false)))
|
||||
:update-prices-success
|
||||
(fn [db [_ prices]]
|
||||
(assoc db
|
||||
:prices prices
|
||||
:prices-loading? false)))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:update-prices-fail
|
||||
(fn [db [_ err]]
|
||||
(log/debug "Unable to get prices: " err)
|
||||
(-> db
|
||||
(assoc-error-message :prices-update err)
|
||||
(assoc :prices-loading? false))))
|
||||
:update-prices-fail
|
||||
(fn [db [_ err]]
|
||||
(log/debug "Unable to get prices: " err)
|
||||
(-> db
|
||||
(assoc-error-message :prices-update err)
|
||||
(assoc :prices-loading? false))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:show-transaction-details
|
||||
(fn [{:keys [db]} [_ hash]]
|
||||
{:db (assoc-in db [:wallet :current-transaction] hash)
|
||||
:dispatch [:navigate-to :wallet-transaction-details]}))
|
||||
:show-transaction-details
|
||||
(fn [{:keys [db]} [_ hash]]
|
||||
{:db (assoc-in db [:wallet :current-transaction] hash)
|
||||
:dispatch [:navigate-to :wallet-transaction-details]}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet/show-sign-transaction
|
||||
(fn [{:keys [db]} [_ id from-chat?]]
|
||||
{:db (assoc-in db [:wallet :send-transaction] {:id id
|
||||
:from-chat? from-chat?})
|
||||
:dispatch [:navigate-to-modal :wallet-send-transaction-modal]}))
|
||||
:wallet/show-sign-transaction
|
||||
(fn [{:keys [db]} [_ id from-chat?]]
|
||||
{:db (assoc-in db [:wallet :send-transaction] {:id id
|
||||
:from-chat? from-chat?})
|
||||
:dispatch [:navigate-to-modal :wallet-send-transaction-modal]}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet/discard-unsigned-transaction
|
||||
(fn [_ [_ transaction-id]]
|
||||
{:discard-transaction transaction-id}))
|
||||
:wallet/discard-unsigned-transaction
|
||||
(fn [_ [_ transaction-id]]
|
||||
{:discard-transaction transaction-id}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet/discard-unsigned-transaction-with-confirmation
|
||||
(fn [_ [_ transaction-id]]
|
||||
{:show-confirmation {:title (i18n/label :t/transactions-delete)
|
||||
:content (i18n/label :t/transactions-delete-content)
|
||||
:confirm-button-text (i18n/label :t/confirm)
|
||||
:on-accept #(re-frame/dispatch [:wallet/discard-unsigned-transaction transaction-id])}}))
|
||||
:wallet/discard-unsigned-transaction-with-confirmation
|
||||
(fn [_ [_ transaction-id]]
|
||||
{:show-confirmation {:title (i18n/label :t/transactions-delete)
|
||||
:content (i18n/label :t/transactions-delete-content)
|
||||
:confirm-button-text (i18n/label :t/confirm)
|
||||
:on-accept #(re-frame/dispatch [:wallet/discard-unsigned-transaction transaction-id])}}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet/update-gas-price
|
||||
(fn [{:keys [db]} [_ edit?]]
|
||||
{:update-gas-price {:web3 (:web3 db)
|
||||
:success-event :wallet/update-gas-price-success
|
||||
:edit? edit?}}))
|
||||
:wallet/update-gas-price
|
||||
(fn [{:keys [db]} [_ edit?]]
|
||||
{:update-gas-price {:web3 (:web3 db)
|
||||
:success-event :wallet/update-gas-price-success
|
||||
:edit? edit?}}))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:wallet/update-gas-price-success
|
||||
(fn [db [_ price edit?]]
|
||||
(assoc-in db [:wallet (if edit? :edit :send-transaction) :gas-price] price)))
|
||||
:wallet/update-gas-price-success
|
||||
(fn [db [_ price edit?]]
|
||||
(assoc-in db [:wallet (if edit? :edit :send-transaction) :gas-price] price)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet/update-estimated-gas
|
||||
(fn [{:keys [db]} [_ obj]]
|
||||
{:update-estimated-gas {:web3 (:web3 db)
|
||||
:obj obj
|
||||
:success-event :wallet/update-estimated-gas-success}}))
|
||||
:wallet/update-estimated-gas
|
||||
(fn [{:keys [db]} [_ obj]]
|
||||
{:update-estimated-gas {:web3 (:web3 db)
|
||||
:obj obj
|
||||
:success-event :wallet/update-estimated-gas-success}}))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:wallet/update-estimated-gas-success
|
||||
(fn [db [_ gas]]
|
||||
(assoc-in db [:wallet :send-transaction :gas] (money/bignumber gas))))
|
||||
:wallet/update-estimated-gas-success
|
||||
(fn [db [_ gas]]
|
||||
(assoc-in db [:wallet :send-transaction :gas] (money/bignumber gas))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet/show-error
|
||||
(fn []
|
||||
{:show-error (i18n/label :t/wallet-error)}))
|
||||
:wallet/show-error
|
||||
(fn []
|
||||
{:show-error (i18n/label :t/wallet-error)}))
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
{:gas (ethereum/estimate-gas symbol)
|
||||
:symbol symbol}))
|
||||
|
||||
|
||||
(defmethod navigation/preload-data! :wallet-request-transaction
|
||||
[db [event]]
|
||||
(if (= event :navigate-back)
|
||||
|
|
|
@ -8,4 +8,4 @@
|
|||
(spec/def ::symbol (spec/nilable keyword?))
|
||||
|
||||
(spec/def :wallet/request-transaction (allowed-keys
|
||||
:opt-un [::amount ::amount-error ::symbol]))
|
||||
:opt-un [::amount ::amount-error ::symbol]))
|
|
@ -8,34 +8,34 @@
|
|||
[status-im.utils.money :as money]))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
::wallet-send-chat-request
|
||||
[re-frame/trim-v]
|
||||
(fn [{{:contacts/keys [contacts]} :db :as cofx} [amount]]
|
||||
(handlers-macro/merge-fx cofx
|
||||
{:dispatch [:send-current-message]}
|
||||
(input-events/select-chat-input-command
|
||||
(assoc (get-in contacts chat-const/request-command-ref) :prefill [amount]) nil true))))
|
||||
::wallet-send-chat-request
|
||||
[re-frame/trim-v]
|
||||
(fn [{{:contacts/keys [contacts]} :db :as cofx} [amount]]
|
||||
(handlers-macro/merge-fx cofx
|
||||
{:dispatch [:send-current-message]}
|
||||
(input-events/select-chat-input-command
|
||||
(assoc (get-in contacts chat-const/request-command-ref) :prefill [amount]) nil true))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet-send-request
|
||||
[re-frame/trim-v]
|
||||
(fn [_ [whisper-identity amount]]
|
||||
(assert whisper-identity)
|
||||
{:dispatch-n [[:navigate-back]
|
||||
[:navigate-to-clean :home]
|
||||
[:add-chat-loaded-event whisper-identity
|
||||
[::wallet-send-chat-request (str (money/wei->ether amount))]]
|
||||
[:start-chat whisper-identity]]}))
|
||||
:wallet-send-request
|
||||
[re-frame/trim-v]
|
||||
(fn [_ [whisper-identity amount]]
|
||||
(assert whisper-identity)
|
||||
{:dispatch-n [[:navigate-back]
|
||||
[:navigate-to-clean :home]
|
||||
[:add-chat-loaded-event whisper-identity
|
||||
[::wallet-send-chat-request (str (money/wei->ether amount))]]
|
||||
[:start-chat whisper-identity]]}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet.request/set-recipient
|
||||
(fn [{:keys [db]} [_ s]]
|
||||
{:db (assoc-in db [:wallet :request-transaction :to] s)}))
|
||||
:wallet.request/set-recipient
|
||||
(fn [{:keys [db]} [_ s]]
|
||||
{:db (assoc-in db [:wallet :request-transaction :to] s)}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet.request/set-and-validate-amount
|
||||
(fn [{:keys [db]} [_ amount]]
|
||||
(let [{:keys [value error]} (wallet-db/parse-amount amount)]
|
||||
{:db (-> db
|
||||
(assoc-in [:wallet :request-transaction :amount] (money/ether->wei value))
|
||||
(assoc-in [:wallet :request-transaction :amount-error] error))})))
|
||||
:wallet.request/set-and-validate-amount
|
||||
(fn [{:keys [db]} [_ amount]]
|
||||
(let [{:keys [value error]} (wallet-db/parse-amount amount)]
|
||||
{:db (-> db
|
||||
(assoc-in [:wallet :request-transaction :amount] (money/ether->wei value))
|
||||
(assoc-in [:wallet :request-transaction :amount-error] error))})))
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
(:require [re-frame.core :as re-frame]))
|
||||
|
||||
(re-frame/reg-sub :wallet.request/transaction
|
||||
:<- [:wallet]
|
||||
:request-transaction)
|
||||
:<- [:wallet]
|
||||
:request-transaction)
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
(defn animate-sign-panel [opacity-value bottom-value]
|
||||
(animation/start
|
||||
(animation/parallel
|
||||
[(animation/timing opacity-value {:toValue 1
|
||||
:duration 500})
|
||||
(animation/timing bottom-value {:toValue 53
|
||||
:easing (.bezier (animation/easing) 0.685, 0.000, 0.025, 1.185)
|
||||
:duration 500})])))
|
||||
(animation/parallel
|
||||
[(animation/timing opacity-value {:toValue 1
|
||||
:duration 500})
|
||||
(animation/timing bottom-value {:toValue 53
|
||||
:easing (.bezier (animation/easing) 0.685, 0.000, 0.025, 1.185)
|
||||
:duration 500})])))
|
|
@ -26,8 +26,8 @@
|
|||
(spec/def ::method (spec/nilable string?))
|
||||
|
||||
(spec/def :wallet/send-transaction (allowed-keys
|
||||
:opt-un [::amount ::to ::to-name ::amount-error ::password
|
||||
::waiting-signal? ::signing? ::id ::later?
|
||||
::camera-flashlight ::in-progress?
|
||||
::wrong-password? ::from-chat? ::symbol ::advanced?
|
||||
::gas ::gas-price ::whisper-identity ::method]))
|
||||
:opt-un [::amount ::to ::to-name ::amount-error ::password
|
||||
::waiting-signal? ::signing? ::id ::later?
|
||||
::camera-flashlight ::in-progress?
|
||||
::wrong-password? ::from-chat? ::symbol ::advanced?
|
||||
::gas ::gas-price ::whisper-identity ::method]))
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
;;;; FX
|
||||
|
||||
(re-frame/reg-fx
|
||||
::accept-transaction
|
||||
(fn [{:keys [password id on-completed]}]
|
||||
(status/approve-sign-requests (list id) password on-completed)))
|
||||
::accept-transaction
|
||||
(fn [{:keys [password id on-completed]}]
|
||||
(status/approve-sign-requests (list id) password on-completed)))
|
||||
|
||||
(defn- send-ethers [{:keys [web3 from to value gas gas-price]}]
|
||||
(.sendTransaction (.-eth web3)
|
||||
|
@ -33,31 +33,31 @@
|
|||
(erc20/transfer web3 contract from to value {:gas gas :gasPrice gas-price} #())))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::send-transaction
|
||||
(fn [{:keys [symbol] :as params}]
|
||||
(case symbol
|
||||
:ETH (send-ethers params)
|
||||
(send-tokens params))))
|
||||
::send-transaction
|
||||
(fn [{:keys [symbol] :as params}]
|
||||
(case symbol
|
||||
:ETH (send-ethers params)
|
||||
(send-tokens params))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::show-transaction-moved
|
||||
(fn [modal?]
|
||||
(utils/show-popup
|
||||
(i18n/label :t/transaction-moved-title)
|
||||
(i18n/label :t/transaction-moved-text)
|
||||
(when modal?
|
||||
#(re-frame/dispatch [:navigate-back])))))
|
||||
::show-transaction-moved
|
||||
(fn [modal?]
|
||||
(utils/show-popup
|
||||
(i18n/label :t/transaction-moved-title)
|
||||
(i18n/label :t/transaction-moved-text)
|
||||
(when modal?
|
||||
#(re-frame/dispatch [:navigate-back])))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::show-transaction-error
|
||||
(fn [message]
|
||||
::show-transaction-error
|
||||
(fn [message]
|
||||
;; (andrey) we need this timeout because modal window conflicts with alert
|
||||
(utils/set-timeout #(utils/show-popup (i18n/label :t/transaction-failed) message) 1000)))
|
||||
(utils/set-timeout #(utils/show-popup (i18n/label :t/transaction-failed) message) 1000)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:discard-transaction
|
||||
(fn [id]
|
||||
(status/discard-sign-request id)))
|
||||
:discard-transaction
|
||||
(fn [id]
|
||||
(status/discard-sign-request id)))
|
||||
|
||||
;;Helper functions
|
||||
|
||||
|
@ -69,23 +69,23 @@
|
|||
;;;; Handlers
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet.send/set-and-validate-amount
|
||||
(fn [{:keys [db]} [_ amount]]
|
||||
(let [{:keys [value error]} (wallet.db/parse-amount amount)]
|
||||
{:db (-> db
|
||||
(assoc-in [:wallet :send-transaction :amount] (money/ether->wei value))
|
||||
(assoc-in [:wallet :send-transaction :amount-error] error))})))
|
||||
:wallet.send/set-and-validate-amount
|
||||
(fn [{:keys [db]} [_ amount]]
|
||||
(let [{:keys [value error]} (wallet.db/parse-amount amount)]
|
||||
{:db (-> db
|
||||
(assoc-in [:wallet :send-transaction :amount] (money/ether->wei value))
|
||||
(assoc-in [:wallet :send-transaction :amount-error] error))})))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet.send/set-symbol
|
||||
(fn [{:keys [db]} [_ symbol]]
|
||||
{:db (-> (assoc-in db [:wallet :send-transaction :symbol] symbol)
|
||||
(assoc-in [:wallet :send-transaction :gas] (ethereum/estimate-gas symbol)))}))
|
||||
:wallet.send/set-symbol
|
||||
(fn [{:keys [db]} [_ symbol]]
|
||||
{:db (-> (assoc-in db [:wallet :send-transaction :symbol] symbol)
|
||||
(assoc-in [:wallet :send-transaction :gas] (ethereum/estimate-gas symbol)))}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet.send/toggle-advanced
|
||||
(fn [{:keys [db]} [_ advanced?]]
|
||||
{:db (assoc-in db [:wallet :send-transaction :advanced?] advanced?)}))
|
||||
:wallet.send/toggle-advanced
|
||||
(fn [{:keys [db]} [_ advanced?]]
|
||||
{:db (assoc-in db [:wallet :send-transaction :advanced?] advanced?)}))
|
||||
|
||||
(def ^:private clear-send-properties {:id nil
|
||||
:signing? false
|
||||
|
@ -100,9 +100,9 @@
|
|||
(dispatch-transaction-completed result))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:sign-later-from-chat
|
||||
(fn [_ _]
|
||||
{::show-transaction-moved true}))
|
||||
:sign-later-from-chat
|
||||
(fn [_ _]
|
||||
{::show-transaction-moved true}))
|
||||
|
||||
(defn prepare-transaction [{:keys [id message_id args]} now]
|
||||
;;NOTE(goranjovic): the transactions started from chat using /send command
|
||||
|
@ -125,63 +125,63 @@
|
|||
|
||||
;;TRANSACTION QUEUED signal from status-go
|
||||
(handlers/register-handler-fx
|
||||
:sign-request-queued
|
||||
(fn [{:keys [db]} [_ transaction]]
|
||||
{:db (update-in db [:wallet :transactions-queue] conj transaction)
|
||||
:dispatch [:check-transactions-queue]}))
|
||||
:sign-request-queued
|
||||
(fn [{:keys [db]} [_ transaction]]
|
||||
{:db (update-in db [:wallet :transactions-queue] conj transaction)
|
||||
:dispatch [:check-transactions-queue]}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:check-transactions-queue
|
||||
[(re-frame/inject-cofx :now)]
|
||||
(fn [{:keys [db now]} _]
|
||||
(let [{:keys [send-transaction transactions-queue]} (:wallet db)
|
||||
{:keys [id method args] :as queued-transaction} (last transactions-queue)
|
||||
db' (update-in db [:wallet :transactions-queue] drop-last)]
|
||||
(when (and (not (:id send-transaction)) queued-transaction)
|
||||
(cond
|
||||
:check-transactions-queue
|
||||
[(re-frame/inject-cofx :now)]
|
||||
(fn [{:keys [db now]} _]
|
||||
(let [{:keys [send-transaction transactions-queue]} (:wallet db)
|
||||
{:keys [id method args] :as queued-transaction} (last transactions-queue)
|
||||
db' (update-in db [:wallet :transactions-queue] drop-last)]
|
||||
(when (and (not (:id send-transaction)) queued-transaction)
|
||||
(cond
|
||||
;;SEND TRANSACTION
|
||||
(= method constants/web3-send-transaction)
|
||||
(= method constants/web3-send-transaction)
|
||||
|
||||
(let [{:keys [gas gasPrice]} args
|
||||
transaction (prepare-transaction queued-transaction now)
|
||||
sending-from-bot-or-dapp? (not (get-in db [:wallet :send-transaction :waiting-signal?]))
|
||||
new-db (assoc-in db' [:wallet :transactions-unsigned id] transaction)
|
||||
sending-db {:id id
|
||||
:method method
|
||||
:from-chat? sending-from-bot-or-dapp?}]
|
||||
(if sending-from-bot-or-dapp?
|
||||
(let [{:keys [gas gasPrice]} args
|
||||
transaction (prepare-transaction queued-transaction now)
|
||||
sending-from-bot-or-dapp? (not (get-in db [:wallet :send-transaction :waiting-signal?]))
|
||||
new-db (assoc-in db' [:wallet :transactions-unsigned id] transaction)
|
||||
sending-db {:id id
|
||||
:method method
|
||||
:from-chat? sending-from-bot-or-dapp?}]
|
||||
(if sending-from-bot-or-dapp?
|
||||
;;SENDING FROM BOT (CHAT) OR DAPP
|
||||
{:db (assoc-in new-db [:wallet :send-transaction] sending-db) ; we need to completely reset sending state here
|
||||
:dispatch-n [[:update-wallet]
|
||||
[:navigate-to-modal :wallet-send-transaction-modal]
|
||||
(when-not (seq gas)
|
||||
[:wallet/update-estimated-gas transaction])
|
||||
(when-not (seq gasPrice)
|
||||
[:wallet/update-gas-price])]}
|
||||
{:db (assoc-in new-db [:wallet :send-transaction] sending-db) ; we need to completely reset sending state here
|
||||
:dispatch-n [[:update-wallet]
|
||||
[:navigate-to-modal :wallet-send-transaction-modal]
|
||||
(when-not (seq gas)
|
||||
[:wallet/update-estimated-gas transaction])
|
||||
(when-not (seq gasPrice)
|
||||
[:wallet/update-gas-price])]}
|
||||
;;WALLET SEND SCREEN WAITING SIGNAL
|
||||
(let [{:keys [later? password]} (get-in db [:wallet :send-transaction])
|
||||
new-db' (update-in new-db [:wallet :send-transaction] merge sending-db)] ; just update sending state as we are in wallet flow
|
||||
(if later?
|
||||
(let [{:keys [later? password]} (get-in db [:wallet :send-transaction])
|
||||
new-db' (update-in new-db [:wallet :send-transaction] merge sending-db)] ; just update sending state as we are in wallet flow
|
||||
(if later?
|
||||
;;SIGN LATER
|
||||
{:db (assoc-in new-db' [:wallet :send-transaction :waiting-signal?] false)
|
||||
:dispatch [:navigate-back]
|
||||
::show-transaction-moved false}
|
||||
{:db (assoc-in new-db' [:wallet :send-transaction :waiting-signal?] false)
|
||||
:dispatch [:navigate-back]
|
||||
::show-transaction-moved false}
|
||||
;;SIGN NOW
|
||||
{:db new-db'
|
||||
::accept-transaction {:id id
|
||||
:password password
|
||||
:on-completed on-transactions-completed}}))))
|
||||
{:db new-db'
|
||||
::accept-transaction {:id id
|
||||
:password password
|
||||
:on-completed on-transactions-completed}}))))
|
||||
;;SIGN MESSAGE
|
||||
(= method constants/web3-personal-sign)
|
||||
(= method constants/web3-personal-sign)
|
||||
|
||||
(let [{:keys [data]} args
|
||||
data' (transport.utils/to-utf8 data)]
|
||||
(if data'
|
||||
{:db (-> db'
|
||||
(assoc-in [:wallet :transactions-unsigned id] {:data data' :id id})
|
||||
(assoc-in [:wallet :send-transaction] {:id id :method method}))
|
||||
:dispatch [:navigate-to-modal :wallet-sign-message-modal]}
|
||||
{:db db'})))))))
|
||||
(let [{:keys [data]} args
|
||||
data' (transport.utils/to-utf8 data)]
|
||||
(if data'
|
||||
{:db (-> db'
|
||||
(assoc-in [:wallet :transactions-unsigned id] {:data data' :id id})
|
||||
(assoc-in [:wallet :send-transaction] {:id id :method method}))
|
||||
:dispatch [:navigate-to-modal :wallet-sign-message-modal]}
|
||||
{:db db'})))))))
|
||||
|
||||
(defn this-transaction-signing? [id signing-id view-id modal]
|
||||
(and (= signing-id id)
|
||||
|
@ -191,25 +191,25 @@
|
|||
|
||||
;;TRANSACTION FAILED signal from status-go
|
||||
(handlers/register-handler-fx
|
||||
:sign-request-failed
|
||||
(fn [{{:keys [view-id modal] :as db} :db} [_ {:keys [id method error_code error_message]}]]
|
||||
(let [send-transaction (get-in db [:wallet :send-transaction])]
|
||||
(case error_code
|
||||
:sign-request-failed
|
||||
(fn [{{:keys [view-id modal] :as db} :db} [_ {:keys [id method error_code error_message]}]]
|
||||
(let [send-transaction (get-in db [:wallet :send-transaction])]
|
||||
(case error_code
|
||||
|
||||
;;WRONG PASSWORD
|
||||
constants/send-transaction-password-error-code
|
||||
{:db (assoc-in db [:wallet :send-transaction :wrong-password?] true)}
|
||||
constants/send-transaction-password-error-code
|
||||
{:db (assoc-in db [:wallet :send-transaction :wrong-password?] true)}
|
||||
|
||||
;;NO ERROR, DISCARDED, TIMEOUT or DEFAULT ERROR
|
||||
(if (this-transaction-signing? id (:id send-transaction) view-id modal)
|
||||
(cond-> {:db (-> db
|
||||
(assoc-in [:wallet :transactions-queue] nil)
|
||||
(update-in [:wallet :transactions-unsigned] dissoc id)
|
||||
(update-in [:wallet :send-transaction] merge clear-send-properties))
|
||||
:dispatch [:navigate-back]}
|
||||
(= method constants/web3-send-transaction)
|
||||
(assoc ::show-transaction-error error_message))
|
||||
{:db (update-in db [:wallet :transactions-unsigned] dissoc id)})))))
|
||||
(if (this-transaction-signing? id (:id send-transaction) view-id modal)
|
||||
(cond-> {:db (-> db
|
||||
(assoc-in [:wallet :transactions-queue] nil)
|
||||
(update-in [:wallet :transactions-unsigned] dissoc id)
|
||||
(update-in [:wallet :send-transaction] merge clear-send-properties))
|
||||
:dispatch [:navigate-back]}
|
||||
(= method constants/web3-send-transaction)
|
||||
(assoc ::show-transaction-error error_message))
|
||||
{:db (update-in db [:wallet :transactions-unsigned] dissoc id)})))))
|
||||
|
||||
(defn prepare-unconfirmed-transaction [db now hash id]
|
||||
(let [transaction (get-in db [:wallet :transactions-unsigned id])]
|
||||
|
@ -224,26 +224,26 @@
|
|||
(dissoc :message-id :id))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
::transaction-completed
|
||||
(fn [{db :db now :now} [_ {:keys [id response]} modal?]]
|
||||
(let [{:keys [hash error]} response
|
||||
{:keys [method]} (get-in db [:wallet :send-transaction])
|
||||
db' (assoc-in db [:wallet :send-transaction :in-progress?] false)]
|
||||
(if (and error (string? error) (not (string/blank? error))) ;; ignore error here, error will be handled in :transaction-failed
|
||||
{:db db'}
|
||||
(merge
|
||||
{:db (cond-> db'
|
||||
(= method constants/web3-send-transaction)
|
||||
(assoc-in [:wallet :transactions hash] (prepare-unconfirmed-transaction db now hash id))
|
||||
true
|
||||
(update-in [:wallet :transactions-unsigned] dissoc id)
|
||||
true
|
||||
(update-in [:wallet :send-transaction] merge clear-send-properties))}
|
||||
(if modal?
|
||||
(cond-> {:dispatch [:navigate-back]}
|
||||
(= method constants/web3-send-transaction)
|
||||
(assoc :dispatch-later [{:ms 400 :dispatch [:navigate-to-modal :wallet-transaction-sent-modal]}]))
|
||||
{:dispatch [:navigate-to :wallet-transaction-sent]}))))))
|
||||
::transaction-completed
|
||||
(fn [{db :db now :now} [_ {:keys [id response]} modal?]]
|
||||
(let [{:keys [hash error]} response
|
||||
{:keys [method]} (get-in db [:wallet :send-transaction])
|
||||
db' (assoc-in db [:wallet :send-transaction :in-progress?] false)]
|
||||
(if (and error (string? error) (not (string/blank? error))) ;; ignore error here, error will be handled in :transaction-failed
|
||||
{:db db'}
|
||||
(merge
|
||||
{:db (cond-> db'
|
||||
(= method constants/web3-send-transaction)
|
||||
(assoc-in [:wallet :transactions hash] (prepare-unconfirmed-transaction db now hash id))
|
||||
true
|
||||
(update-in [:wallet :transactions-unsigned] dissoc id)
|
||||
true
|
||||
(update-in [:wallet :send-transaction] merge clear-send-properties))}
|
||||
(if modal?
|
||||
(cond-> {:dispatch [:navigate-back]}
|
||||
(= method constants/web3-send-transaction)
|
||||
(assoc :dispatch-later [{:ms 400 :dispatch [:navigate-to-modal :wallet-transaction-sent-modal]}]))
|
||||
{:dispatch [:navigate-to :wallet-transaction-sent]}))))))
|
||||
|
||||
(defn on-transactions-modal-completed [raw-results]
|
||||
(let [results (:results (types/json->clj raw-results))]
|
||||
|
@ -251,37 +251,37 @@
|
|||
(dispatch-transaction-completed result true))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet/sign-transaction
|
||||
(fn [{{:keys [web3] :as db} :db} [_ later?]]
|
||||
(let [db' (assoc-in db [:wallet :send-transaction :wrong-password?] false)
|
||||
network (:network db)
|
||||
{:keys [amount id password to symbol gas gas-price]} (get-in db [:wallet :send-transaction])]
|
||||
(if id
|
||||
{::accept-transaction {:id id
|
||||
:password password
|
||||
:on-completed on-transactions-completed}
|
||||
:db (assoc-in db' [:wallet :send-transaction :in-progress?] true)}
|
||||
{:db (update-in db' [:wallet :send-transaction] assoc
|
||||
:waiting-signal? true
|
||||
:later? later?
|
||||
:in-progress? true)
|
||||
::send-transaction {:web3 web3
|
||||
:from (get-in db [:account/account :address])
|
||||
:to to
|
||||
:value amount
|
||||
:gas gas
|
||||
:gas-price gas-price
|
||||
:symbol symbol
|
||||
:network network}}))))
|
||||
:wallet/sign-transaction
|
||||
(fn [{{:keys [web3] :as db} :db} [_ later?]]
|
||||
(let [db' (assoc-in db [:wallet :send-transaction :wrong-password?] false)
|
||||
network (:network db)
|
||||
{:keys [amount id password to symbol gas gas-price]} (get-in db [:wallet :send-transaction])]
|
||||
(if id
|
||||
{::accept-transaction {:id id
|
||||
:password password
|
||||
:on-completed on-transactions-completed}
|
||||
:db (assoc-in db' [:wallet :send-transaction :in-progress?] true)}
|
||||
{:db (update-in db' [:wallet :send-transaction] assoc
|
||||
:waiting-signal? true
|
||||
:later? later?
|
||||
:in-progress? true)
|
||||
::send-transaction {:web3 web3
|
||||
:from (get-in db [:account/account :address])
|
||||
:to to
|
||||
:value amount
|
||||
:gas gas
|
||||
:gas-price gas-price
|
||||
:symbol symbol
|
||||
:network network}}))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet/sign-transaction-modal
|
||||
(fn [{db :db} _]
|
||||
(let [{:keys [id password]} (get-in db [:wallet :send-transaction])]
|
||||
{:db (assoc-in db [:wallet :send-transaction :in-progress?] true)
|
||||
::accept-transaction {:id id
|
||||
:password password
|
||||
:on-completed on-transactions-modal-completed}})))
|
||||
:wallet/sign-transaction-modal
|
||||
(fn [{db :db} _]
|
||||
(let [{:keys [id password]} (get-in db [:wallet :send-transaction])]
|
||||
{:db (assoc-in db [:wallet :send-transaction :in-progress?] true)
|
||||
::accept-transaction {:id id
|
||||
:password password
|
||||
:on-completed on-transactions-modal-completed}})))
|
||||
|
||||
(defn discard-transaction
|
||||
[{:keys [db]}]
|
||||
|
@ -291,69 +291,69 @@
|
|||
{:discard-transaction id}))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet/discard-transaction
|
||||
(fn [cofx _]
|
||||
(discard-transaction cofx)))
|
||||
:wallet/discard-transaction
|
||||
(fn [cofx _]
|
||||
(discard-transaction cofx)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet/discard-transaction-navigate-back
|
||||
(fn [cofx _]
|
||||
(-> cofx
|
||||
discard-transaction
|
||||
(assoc :dispatch [:navigate-back]))))
|
||||
:wallet/discard-transaction-navigate-back
|
||||
(fn [cofx _]
|
||||
(-> cofx
|
||||
discard-transaction
|
||||
(assoc :dispatch [:navigate-back]))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet/cancel-signing-modal
|
||||
(fn [{:keys [db]} _]
|
||||
{:db (update-in db [:wallet :send-transaction] assoc
|
||||
:signing? false
|
||||
:wrong-password? false
|
||||
:password nil)}))
|
||||
:wallet/cancel-signing-modal
|
||||
(fn [{:keys [db]} _]
|
||||
{:db (update-in db [:wallet :send-transaction] assoc
|
||||
:signing? false
|
||||
:wrong-password? false
|
||||
:password nil)}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet.send/set-password
|
||||
(fn [{:keys [db]} [_ password]]
|
||||
{:db (assoc-in db [:wallet :send-transaction :password] password)}))
|
||||
:wallet.send/set-password
|
||||
(fn [{:keys [db]} [_ password]]
|
||||
{:db (assoc-in db [:wallet :send-transaction :password] password)}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet.send/set-signing?
|
||||
(fn [{:keys [db]} [_ signing?]]
|
||||
{:db (assoc-in db [:wallet :send-transaction :signing?] signing?)}))
|
||||
:wallet.send/set-signing?
|
||||
(fn [{:keys [db]} [_ signing?]]
|
||||
{:db (assoc-in db [:wallet :send-transaction :signing?] signing?)}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet.send/edit-gas
|
||||
(fn [{:keys [db]} [_ gas]]
|
||||
{:db (assoc-in db [:wallet :edit :gas] (money/bignumber gas))}))
|
||||
:wallet.send/edit-gas
|
||||
(fn [{:keys [db]} [_ gas]]
|
||||
{:db (assoc-in db [:wallet :edit :gas] (money/bignumber gas))}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet.send/edit-gas-price
|
||||
(fn [{:keys [db]} [_ gas-price]]
|
||||
{:db (assoc-in db [:wallet :edit :gas-price] (money/bignumber gas-price))}))
|
||||
:wallet.send/edit-gas-price
|
||||
(fn [{:keys [db]} [_ gas-price]]
|
||||
{:db (assoc-in db [:wallet :edit :gas-price] (money/bignumber gas-price))}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet.send/set-gas-details
|
||||
(fn [{:keys [db]} [_ gas gas-price]]
|
||||
{:db (-> db
|
||||
(assoc-in [:wallet :send-transaction :gas] gas)
|
||||
(assoc-in [:wallet :send-transaction :gas-price] gas-price))}))
|
||||
:wallet.send/set-gas-details
|
||||
(fn [{:keys [db]} [_ gas gas-price]]
|
||||
{:db (-> db
|
||||
(assoc-in [:wallet :send-transaction :gas] gas)
|
||||
(assoc-in [:wallet :send-transaction :gas-price] gas-price))}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet.send/clear-gas
|
||||
(fn [{:keys [db]}]
|
||||
{:db (update db :wallet dissoc :edit)}))
|
||||
:wallet.send/clear-gas
|
||||
(fn [{:keys [db]}]
|
||||
{:db (update db :wallet dissoc :edit)}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet.send/reset-gas-default
|
||||
(fn [{:keys [db]}]
|
||||
{:dispatch [:wallet/update-gas-price true]
|
||||
:db (update-in db [:wallet :edit]
|
||||
assoc
|
||||
:gas (ethereum/estimate-gas (get-in db [:wallet :send-transaction :symbol])))}))
|
||||
:wallet.send/reset-gas-default
|
||||
(fn [{:keys [db]}]
|
||||
{:dispatch [:wallet/update-gas-price true]
|
||||
:db (update-in db [:wallet :edit]
|
||||
assoc
|
||||
:gas (ethereum/estimate-gas (get-in db [:wallet :send-transaction :symbol])))}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:close-transaction-sent-screen
|
||||
(fn [{:keys [db]} _]
|
||||
{:dispatch (if (= :wallet-send-transaction (second (:navigation-stack db)))
|
||||
[:navigate-to-clean :wallet]
|
||||
[:navigate-back])
|
||||
:dispatch-later [{:ms 400 :dispatch [:check-transactions-queue]}]}))
|
||||
:close-transaction-sent-screen
|
||||
(fn [{:keys [db]} _]
|
||||
{:dispatch (if (= :wallet-send-transaction (second (:navigation-stack db)))
|
||||
[:navigate-to-clean :wallet]
|
||||
[:navigate-back])
|
||||
:dispatch-later [{:ms 400 :dispatch [:check-transactions-queue]}]}))
|
||||
|
|
|
@ -4,60 +4,59 @@
|
|||
[status-im.utils.hex :as utils.hex]))
|
||||
|
||||
(re-frame/reg-sub ::send-transaction
|
||||
:<- [:wallet]
|
||||
(fn [wallet]
|
||||
(let [transaction (:send-transaction wallet)]
|
||||
:<- [:wallet]
|
||||
(fn [wallet]
|
||||
(let [transaction (:send-transaction wallet)]
|
||||
;NOTE(goranjovic): the transactions started from chat using /send command
|
||||
; are only in ether, so this parameter defaults to ETH
|
||||
(if (:symbol transaction)
|
||||
transaction
|
||||
(assoc transaction :symbol :ETH)))))
|
||||
|
||||
(if (:symbol transaction)
|
||||
transaction
|
||||
(assoc transaction :symbol :ETH)))))
|
||||
|
||||
(re-frame/reg-sub :wallet.send/symbol
|
||||
:<- [::send-transaction]
|
||||
(fn [send-transaction]
|
||||
(:symbol send-transaction)))
|
||||
:<- [::send-transaction]
|
||||
(fn [send-transaction]
|
||||
(:symbol send-transaction)))
|
||||
|
||||
(re-frame/reg-sub :wallet.send/advanced?
|
||||
:<- [::send-transaction]
|
||||
(fn [send-transaction]
|
||||
(:advanced? send-transaction)))
|
||||
:<- [::send-transaction]
|
||||
(fn [send-transaction]
|
||||
(:advanced? send-transaction)))
|
||||
|
||||
(re-frame/reg-sub :wallet.send/camera-flashlight
|
||||
:<- [::send-transaction]
|
||||
(fn [send-transaction]
|
||||
(:camera-flashlight send-transaction)))
|
||||
:<- [::send-transaction]
|
||||
(fn [send-transaction]
|
||||
(:camera-flashlight send-transaction)))
|
||||
|
||||
(re-frame/reg-sub :wallet.send/wrong-password?
|
||||
:<- [::send-transaction]
|
||||
(fn [send-transaction]
|
||||
(:wrong-password? send-transaction)))
|
||||
:<- [::send-transaction]
|
||||
(fn [send-transaction]
|
||||
(:wrong-password? send-transaction)))
|
||||
|
||||
(re-frame/reg-sub :wallet.send/sign-password-enabled?
|
||||
:<- [::send-transaction]
|
||||
(fn [{:keys [password]}]
|
||||
(and (not (nil? password)) (not= password ""))))
|
||||
:<- [::send-transaction]
|
||||
(fn [{:keys [password]}]
|
||||
(and (not (nil? password)) (not= password ""))))
|
||||
|
||||
(re-frame/reg-sub ::unsigned-transactions
|
||||
:<- [:wallet]
|
||||
(fn [wallet]
|
||||
(:transactions-unsigned wallet)))
|
||||
:<- [:wallet]
|
||||
(fn [wallet]
|
||||
(:transactions-unsigned wallet)))
|
||||
|
||||
(re-frame/reg-sub ::unsigned-transaction
|
||||
:<- [::send-transaction]
|
||||
:<- [::unsigned-transactions]
|
||||
(fn [[send-transaction unsigned-transactions]]
|
||||
(when-let [unsigned-transaction (get unsigned-transactions
|
||||
(:id send-transaction))]
|
||||
(merge send-transaction
|
||||
unsigned-transaction
|
||||
{:gas (or (:gas unsigned-transaction) (:gas send-transaction))
|
||||
:gas-price (or (:gas-price unsigned-transaction) (:gas-price send-transaction))}))))
|
||||
:<- [::send-transaction]
|
||||
:<- [::unsigned-transactions]
|
||||
(fn [[send-transaction unsigned-transactions]]
|
||||
(when-let [unsigned-transaction (get unsigned-transactions
|
||||
(:id send-transaction))]
|
||||
(merge send-transaction
|
||||
unsigned-transaction
|
||||
{:gas (or (:gas unsigned-transaction) (:gas send-transaction))
|
||||
:gas-price (or (:gas-price unsigned-transaction) (:gas-price send-transaction))}))))
|
||||
|
||||
(re-frame/reg-sub :wallet/edit
|
||||
:<- [:wallet]
|
||||
:edit)
|
||||
:<- [:wallet]
|
||||
:edit)
|
||||
|
||||
(defn sign-enabled? [amount-error to amount]
|
||||
(and
|
||||
|
@ -66,21 +65,21 @@
|
|||
(not (nil? amount)) (not= amount "")))
|
||||
|
||||
(re-frame/reg-sub :wallet.send/transaction
|
||||
:<- [::send-transaction]
|
||||
:<- [:balance]
|
||||
(fn [[{:keys [amount symbol] :as transaction} balance]]
|
||||
(assoc transaction :sufficient-funds? (or (nil? amount)
|
||||
(money/sufficient-funds? amount (get balance symbol))))))
|
||||
:<- [::send-transaction]
|
||||
:<- [:balance]
|
||||
(fn [[{:keys [amount symbol] :as transaction} balance]]
|
||||
(assoc transaction :sufficient-funds? (or (nil? amount)
|
||||
(money/sufficient-funds? amount (get balance symbol))))))
|
||||
|
||||
(re-frame/reg-sub :wallet.send/unsigned-transaction
|
||||
:<- [::unsigned-transaction]
|
||||
:<- [:get-contacts-by-address]
|
||||
:<- [:balance]
|
||||
(fn [[{:keys [value to symbol] :as transaction} contacts balance]]
|
||||
(when transaction
|
||||
(let [contact (contacts (utils.hex/normalize-hex to))
|
||||
sufficient-funds? (money/sufficient-funds? value (get balance symbol))]
|
||||
(cond-> (assoc transaction
|
||||
:amount value
|
||||
:sufficient-funds? sufficient-funds?)
|
||||
contact (assoc :to-name (:name contact)))))))
|
||||
:<- [::unsigned-transaction]
|
||||
:<- [:get-contacts-by-address]
|
||||
:<- [:balance]
|
||||
(fn [[{:keys [value to symbol] :as transaction} contacts balance]]
|
||||
(when transaction
|
||||
(let [contact (contacts (utils.hex/normalize-hex to))
|
||||
sufficient-funds? (money/sufficient-funds? value (get balance symbol))]
|
||||
(cond-> (assoc transaction
|
||||
:amount value
|
||||
:sufficient-funds? sufficient-funds?)
|
||||
contact (assoc :to-name (:name contact)))))))
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
(defn sign-later-popup
|
||||
[from-chat?]
|
||||
(utils/show-question
|
||||
(i18n/label :t/sign-later-title)
|
||||
(i18n/label :t/sign-later-text)
|
||||
#(re-frame/dispatch (if from-chat?
|
||||
[:sign-later-from-chat]
|
||||
[:wallet/sign-transaction true]))))
|
||||
(i18n/label :t/sign-later-title)
|
||||
(i18n/label :t/sign-later-text)
|
||||
#(re-frame/dispatch (if from-chat?
|
||||
[:sign-later-from-chat]
|
||||
[:wallet/sign-transaction true]))))
|
||||
|
||||
(defview sign-panel [message?]
|
||||
(letsubs [account [:get-current-account]
|
||||
|
@ -78,9 +78,9 @@
|
|||
|
||||
(defn- sign-enabled? [amount-error to amount]
|
||||
(and
|
||||
(nil? amount-error)
|
||||
(not (nil? to)) (not= to "")
|
||||
(not (nil? amount))))
|
||||
(nil? amount-error)
|
||||
(not (nil? to)) (not= to "")
|
||||
(not (nil? amount))))
|
||||
|
||||
;; "Sign Later" and "Sign Transaction >" buttons
|
||||
(defn- sign-buttons [amount-error to amount sufficient-funds? sign-later-handler modal?]
|
||||
|
@ -233,8 +233,8 @@
|
|||
sufficient-funds?
|
||||
(if modal?
|
||||
(if from-chat?
|
||||
#(sign-later-popup true)
|
||||
#(re-frame/dispatch [:navigate-back]))
|
||||
#(sign-later-popup true)
|
||||
#(re-frame/dispatch [:navigate-back]))
|
||||
#(sign-later-popup false))
|
||||
modal?])
|
||||
(when signing?
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
(disj ids id)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:wallet.settings/toggle-visible-token
|
||||
(fn [{{:keys [network account/account] :as db} :db :as cofx} [_ symbol checked?]]
|
||||
(let [chain (ethereum/network->chain-keyword network)
|
||||
settings (get account :settings)
|
||||
new-settings (update-in settings [:wallet :visible-tokens chain] #(toggle-checked % symbol checked?))]
|
||||
(accounts/update-settings new-settings cofx))))
|
||||
:wallet.settings/toggle-visible-token
|
||||
(fn [{{:keys [network account/account] :as db} :db :as cofx} [_ symbol checked?]]
|
||||
(let [chain (ethereum/network->chain-keyword network)
|
||||
settings (get account :settings)
|
||||
new-settings (update-in settings [:wallet :visible-tokens chain] #(toggle-checked % symbol checked?))]
|
||||
(accounts/update-settings new-settings cofx))))
|
||||
|
|
|
@ -35,15 +35,15 @@
|
|||
|
||||
(defn cartouche-content-wrapper [disabled?]
|
||||
(merge
|
||||
{:flex-direction :row
|
||||
:margin-top 8
|
||||
:border-radius styles/border-radius
|
||||
:padding-left 14
|
||||
:padding-right 8}
|
||||
(if disabled?
|
||||
{:border-color colors/white-light-transparent
|
||||
:border-width 1}
|
||||
{:background-color colors/white-transparent})))
|
||||
{:flex-direction :row
|
||||
:margin-top 8
|
||||
:border-radius styles/border-radius
|
||||
:padding-left 14
|
||||
:padding-right 8}
|
||||
(if disabled?
|
||||
{:border-color colors/white-light-transparent
|
||||
:border-width 1}
|
||||
{:background-color colors/white-transparent})))
|
||||
|
||||
(def cartouche-icon-wrapper
|
||||
{:flex 1
|
||||
|
|
|
@ -5,38 +5,38 @@
|
|||
[status-im.utils.ethereum.tokens :as tokens]))
|
||||
|
||||
(re-frame/reg-sub :wallet
|
||||
(fn [db]
|
||||
(:wallet db)))
|
||||
(fn [db]
|
||||
(:wallet db)))
|
||||
|
||||
(re-frame/reg-sub :balance
|
||||
:<- [:wallet]
|
||||
(fn [wallet]
|
||||
(:balance wallet)))
|
||||
:<- [:wallet]
|
||||
(fn [wallet]
|
||||
(:balance wallet)))
|
||||
|
||||
(re-frame/reg-sub :prices
|
||||
(fn [db]
|
||||
(:prices db)))
|
||||
(fn [db]
|
||||
(:prices db)))
|
||||
|
||||
(re-frame/reg-sub :price
|
||||
:<- [:prices]
|
||||
(fn [prices [_ fsym tsym]]
|
||||
(get-in prices [fsym tsym :price])))
|
||||
:<- [:prices]
|
||||
(fn [prices [_ fsym tsym]]
|
||||
(get-in prices [fsym tsym :price])))
|
||||
|
||||
(re-frame/reg-sub :last-day
|
||||
:<- [:prices]
|
||||
(fn [prices [_ fsym tsym]]
|
||||
(get-in prices [fsym tsym :last-day])))
|
||||
:<- [:prices]
|
||||
(fn [prices [_ fsym tsym]]
|
||||
(get-in prices [fsym tsym :last-day])))
|
||||
|
||||
(re-frame/reg-sub :asset-value
|
||||
(fn [[_ fsym tsym]]
|
||||
[(re-frame/subscribe [:balance])
|
||||
(re-frame/subscribe [:price fsym tsym])])
|
||||
(fn [[balance price] [_ fsym tsym]]
|
||||
(when (and balance price)
|
||||
(-> (money/wei->ether (get balance fsym))
|
||||
(money/eth->fiat price)
|
||||
(money/with-precision 2)
|
||||
str))))
|
||||
(fn [[_ fsym tsym]]
|
||||
[(re-frame/subscribe [:balance])
|
||||
(re-frame/subscribe [:price fsym tsym])])
|
||||
(fn [[balance price] [_ fsym tsym]]
|
||||
(when (and balance price)
|
||||
(-> (money/wei->ether (get balance fsym))
|
||||
(money/eth->fiat price)
|
||||
(money/with-precision 2)
|
||||
str))))
|
||||
|
||||
(defn- get-balance-total-value [balance prices currency]
|
||||
(->> balance
|
||||
|
@ -48,52 +48,52 @@
|
|||
acc)) 0)))
|
||||
|
||||
(re-frame/reg-sub :portfolio-value
|
||||
:<- [:balance]
|
||||
:<- [:prices]
|
||||
(fn [[balance prices] [_ currency]]
|
||||
(if (and balance prices)
|
||||
(let [balance-total-value (get-balance-total-value balance prices currency)]
|
||||
(-> balance-total-value
|
||||
(money/with-precision 2)
|
||||
str))
|
||||
"...")))
|
||||
:<- [:balance]
|
||||
:<- [:prices]
|
||||
(fn [[balance prices] [_ currency]]
|
||||
(if (and balance prices)
|
||||
(let [balance-total-value (get-balance-total-value balance prices currency)]
|
||||
(-> balance-total-value
|
||||
(money/with-precision 2)
|
||||
str))
|
||||
"...")))
|
||||
|
||||
(re-frame/reg-sub :prices-loading?
|
||||
(fn [db]
|
||||
(:prices-loading? db)))
|
||||
(fn [db]
|
||||
(:prices-loading? db)))
|
||||
|
||||
(re-frame/reg-sub :wallet/balance-loading?
|
||||
:<- [:wallet]
|
||||
(fn [wallet]
|
||||
(:balance-loading? wallet)))
|
||||
:<- [:wallet]
|
||||
(fn [wallet]
|
||||
(:balance-loading? wallet)))
|
||||
|
||||
(re-frame/reg-sub :wallet/error-message?
|
||||
:<- [:wallet]
|
||||
(fn [wallet]
|
||||
(or (get-in wallet [:errors :balance-update])
|
||||
(get-in wallet [:errors :prices-update]))))
|
||||
:<- [:wallet]
|
||||
(fn [wallet]
|
||||
(or (get-in wallet [:errors :balance-update])
|
||||
(get-in wallet [:errors :prices-update]))))
|
||||
|
||||
(re-frame/reg-sub :get-wallet-unread-messages-number
|
||||
(fn [db]
|
||||
0))
|
||||
(fn [db]
|
||||
0))
|
||||
|
||||
(re-frame/reg-sub :wallet/visible-tokens-symbols
|
||||
:<- [:network]
|
||||
:<- [:get-current-account]
|
||||
(fn [[network current-account]]
|
||||
(let [chain (ethereum/network->chain-keyword network)]
|
||||
(get-in current-account [:settings :wallet :visible-tokens chain]))))
|
||||
:<- [:network]
|
||||
:<- [:get-current-account]
|
||||
(fn [[network current-account]]
|
||||
(let [chain (ethereum/network->chain-keyword network)]
|
||||
(get-in current-account [:settings :wallet :visible-tokens chain]))))
|
||||
|
||||
(re-frame/reg-sub :wallet/visible-assets
|
||||
:<- [:network]
|
||||
:<- [:wallet/visible-tokens-symbols]
|
||||
(fn [[network visible-tokens-symbols]]
|
||||
(conj (filter #(contains? visible-tokens-symbols (:symbol %))
|
||||
(tokens/tokens-for (ethereum/network->chain-keyword network)))
|
||||
tokens/ethereum)))
|
||||
:<- [:network]
|
||||
:<- [:wallet/visible-tokens-symbols]
|
||||
(fn [[network visible-tokens-symbols]]
|
||||
(conj (filter #(contains? visible-tokens-symbols (:symbol %))
|
||||
(tokens/tokens-for (ethereum/network->chain-keyword network)))
|
||||
tokens/ethereum)))
|
||||
|
||||
(re-frame/reg-sub :wallet/visible-assets-with-amount
|
||||
:<- [:balance]
|
||||
:<- [:wallet/visible-assets]
|
||||
(fn [[balance visible-assets]]
|
||||
(map #(assoc % :amount (get balance (:symbol %))) visible-assets)))
|
||||
:<- [:balance]
|
||||
:<- [:wallet/visible-assets]
|
||||
(fn [[balance visible-assets]]
|
||||
(map #(assoc % :amount (get balance (:symbol %))) visible-assets)))
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
(update-in db [:wallet.transactions :filters] f))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:wallet.transactions/filter
|
||||
(fn [db [_ path checked?]]
|
||||
(update-filters db #(mark-checked % path checked?))))
|
||||
:wallet.transactions/filter
|
||||
(fn [db [_ path checked?]]
|
||||
(update-filters db #(mark-checked % path checked?))))
|
||||
|
||||
(handlers/register-handler-db
|
||||
:wallet.transactions/filter-all
|
||||
(fn [db]
|
||||
(update-filters db mark-all-checked)))
|
||||
:wallet.transactions/filter-all
|
||||
(fn [db]
|
||||
(update-filters db mark-all-checked)))
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
[status-im.utils.transactions :as transactions]))
|
||||
|
||||
(reg-sub :wallet.transactions/transactions-loading?
|
||||
:<- [:wallet]
|
||||
(fn [wallet]
|
||||
(:transactions-loading? wallet)))
|
||||
:<- [:wallet]
|
||||
(fn [wallet]
|
||||
(:transactions-loading? wallet)))
|
||||
|
||||
(reg-sub :wallet.transactions/current-tab
|
||||
:<- [:wallet]
|
||||
(fn [wallet]
|
||||
(get wallet :current-tab 0)))
|
||||
:<- [:wallet]
|
||||
(fn [wallet]
|
||||
(get wallet :current-tab 0)))
|
||||
|
||||
(defn enrich-transaction [{:keys [type to from timestamp] :as transaction} contacts]
|
||||
(let [[contact-address key-contact key-wallet] (if (= type :inbound)
|
||||
|
@ -28,18 +28,18 @@
|
|||
:time-formatted (datetime/timestamp->time timestamp)))))
|
||||
|
||||
(reg-sub :wallet.transactions/transactions
|
||||
:<- [:wallet]
|
||||
:<- [:get-contacts-by-address]
|
||||
(fn [[wallet contacts]]
|
||||
(reduce (fn [acc [hash transaction]]
|
||||
(assoc acc hash (enrich-transaction transaction contacts)))
|
||||
{}
|
||||
(:transactions wallet))))
|
||||
:<- [:wallet]
|
||||
:<- [:get-contacts-by-address]
|
||||
(fn [[wallet contacts]]
|
||||
(reduce (fn [acc [hash transaction]]
|
||||
(assoc acc hash (enrich-transaction transaction contacts)))
|
||||
{}
|
||||
(:transactions wallet))))
|
||||
|
||||
(reg-sub :wallet.transactions/grouped-transactions
|
||||
:<- [:wallet.transactions/transactions]
|
||||
(fn [transactions]
|
||||
(group-by :type (vals transactions))))
|
||||
:<- [:wallet.transactions/transactions]
|
||||
(fn [transactions]
|
||||
(group-by :type (vals transactions))))
|
||||
|
||||
(defn- format-unsigned-transaction [{:keys [id] :as transaction}]
|
||||
(assoc transaction
|
||||
|
@ -49,44 +49,44 @@
|
|||
:hash id))
|
||||
|
||||
(reg-sub :wallet/unsigned-transactions
|
||||
:<- [:wallet]
|
||||
:<- [:get-contacts-by-address]
|
||||
(fn [[wallet contacts]]
|
||||
(map #(enrich-transaction % contacts) (vals (:transactions-unsigned wallet)))))
|
||||
:<- [:wallet]
|
||||
:<- [:get-contacts-by-address]
|
||||
(fn [[wallet contacts]]
|
||||
(map #(enrich-transaction % contacts) (vals (:transactions-unsigned wallet)))))
|
||||
|
||||
(reg-sub :wallet.transactions/unsigned-transactions
|
||||
:<- [:wallet/unsigned-transactions]
|
||||
(fn [transactions]
|
||||
(reduce (fn [acc {:keys [id] :as transaction}]
|
||||
(assoc acc id (format-unsigned-transaction transaction)))
|
||||
{}
|
||||
transactions)))
|
||||
:<- [:wallet/unsigned-transactions]
|
||||
(fn [transactions]
|
||||
(reduce (fn [acc {:keys [id] :as transaction}]
|
||||
(assoc acc id (format-unsigned-transaction transaction)))
|
||||
{}
|
||||
transactions)))
|
||||
|
||||
(reg-sub :wallet.transactions/unsigned-transactions-count
|
||||
:<- [:wallet.transactions/unsigned-transactions]
|
||||
(fn [unsigned-transactions]
|
||||
(count unsigned-transactions)))
|
||||
:<- [:wallet.transactions/unsigned-transactions]
|
||||
(fn [unsigned-transactions]
|
||||
(count unsigned-transactions)))
|
||||
|
||||
(reg-sub :wallet.transactions/unsigned-transactions-list
|
||||
:<- [:wallet.transactions/unsigned-transactions]
|
||||
(fn [unsigned-transactions]
|
||||
(vals unsigned-transactions)))
|
||||
:<- [:wallet.transactions/unsigned-transactions]
|
||||
(fn [unsigned-transactions]
|
||||
(vals unsigned-transactions)))
|
||||
|
||||
(reg-sub :wallet.transactions/postponed-transactions-list
|
||||
:<- [:wallet.transactions/grouped-transactions]
|
||||
(fn [{:keys [postponed]}]
|
||||
(when postponed
|
||||
{:title "Postponed"
|
||||
:key :postponed
|
||||
:data postponed})))
|
||||
:<- [:wallet.transactions/grouped-transactions]
|
||||
(fn [{:keys [postponed]}]
|
||||
(when postponed
|
||||
{:title "Postponed"
|
||||
:key :postponed
|
||||
:data postponed})))
|
||||
|
||||
(reg-sub :wallet.transactions/pending-transactions-list
|
||||
:<- [:wallet.transactions/grouped-transactions]
|
||||
(fn [{:keys [pending]}]
|
||||
(when pending
|
||||
{:title "Pending"
|
||||
:key :pending
|
||||
:data pending})))
|
||||
:<- [:wallet.transactions/grouped-transactions]
|
||||
(fn [{:keys [pending]}]
|
||||
(when pending
|
||||
{:title "Pending"
|
||||
:key :pending
|
||||
:data pending})))
|
||||
|
||||
(defn group-transactions-by-date [transactions]
|
||||
(->> transactions
|
||||
|
@ -99,68 +99,68 @@
|
|||
:data (sort-by :timestamp > transactions)}))))
|
||||
|
||||
(reg-sub :wallet.transactions/completed-transactions-list
|
||||
:<- [:wallet.transactions/grouped-transactions]
|
||||
(fn [{:keys [inbound outbound]}]
|
||||
(group-transactions-by-date (into inbound outbound))))
|
||||
:<- [:wallet.transactions/grouped-transactions]
|
||||
(fn [{:keys [inbound outbound]}]
|
||||
(group-transactions-by-date (into inbound outbound))))
|
||||
|
||||
(reg-sub :wallet.transactions/transactions-history-list
|
||||
:<- [:wallet.transactions/postponed-transactions-list]
|
||||
:<- [:wallet.transactions/pending-transactions-list]
|
||||
:<- [:wallet.transactions/completed-transactions-list]
|
||||
(fn [[postponed pending completed]]
|
||||
(cond-> []
|
||||
postponed (into postponed)
|
||||
pending (into pending)
|
||||
completed (into completed))))
|
||||
:<- [:wallet.transactions/postponed-transactions-list]
|
||||
:<- [:wallet.transactions/pending-transactions-list]
|
||||
:<- [:wallet.transactions/completed-transactions-list]
|
||||
(fn [[postponed pending completed]]
|
||||
(cond-> []
|
||||
postponed (into postponed)
|
||||
pending (into pending)
|
||||
completed (into completed))))
|
||||
|
||||
(reg-sub :wallet.transactions/current-transaction
|
||||
:<- [:wallet]
|
||||
(fn [wallet]
|
||||
(:current-transaction wallet)))
|
||||
:<- [:wallet]
|
||||
(fn [wallet]
|
||||
(:current-transaction wallet)))
|
||||
|
||||
(reg-sub :wallet.transactions/transaction-details
|
||||
:<- [:wallet.transactions/unsigned-transactions]
|
||||
:<- [:wallet.transactions/transactions]
|
||||
:<- [:wallet.transactions/current-transaction]
|
||||
:<- [:network]
|
||||
(fn [[unsigned-transactions transactions current-transaction network]]
|
||||
(let [transactions (merge transactions unsigned-transactions)
|
||||
{:keys [gas-used gas-price hash timestamp type] :as transaction} (get transactions current-transaction)]
|
||||
(when transaction
|
||||
(merge transaction
|
||||
{:gas-price-eth (money/wei->str :eth gas-price)
|
||||
:gas-price-gwei (money/wei->str :gwei gas-price)
|
||||
:date (datetime/timestamp->long-date timestamp)}
|
||||
(if (= type :unsigned)
|
||||
{:block (i18n/label :not-applicable)
|
||||
:cost (i18n/label :not-applicable)
|
||||
:gas-limit (i18n/label :not-applicable)
|
||||
:gas-used (i18n/label :not-applicable)
|
||||
:nonce (i18n/label :not-applicable)
|
||||
:hash (i18n/label :not-applicable)}
|
||||
{:cost (when gas-used
|
||||
(money/wei->str :eth (money/fee-value gas-used gas-price)))
|
||||
:url (transactions/get-transaction-details-url network hash)}))))))
|
||||
:<- [:wallet.transactions/unsigned-transactions]
|
||||
:<- [:wallet.transactions/transactions]
|
||||
:<- [:wallet.transactions/current-transaction]
|
||||
:<- [:network]
|
||||
(fn [[unsigned-transactions transactions current-transaction network]]
|
||||
(let [transactions (merge transactions unsigned-transactions)
|
||||
{:keys [gas-used gas-price hash timestamp type] :as transaction} (get transactions current-transaction)]
|
||||
(when transaction
|
||||
(merge transaction
|
||||
{:gas-price-eth (money/wei->str :eth gas-price)
|
||||
:gas-price-gwei (money/wei->str :gwei gas-price)
|
||||
:date (datetime/timestamp->long-date timestamp)}
|
||||
(if (= type :unsigned)
|
||||
{:block (i18n/label :not-applicable)
|
||||
:cost (i18n/label :not-applicable)
|
||||
:gas-limit (i18n/label :not-applicable)
|
||||
:gas-used (i18n/label :not-applicable)
|
||||
:nonce (i18n/label :not-applicable)
|
||||
:hash (i18n/label :not-applicable)}
|
||||
{:cost (when gas-used
|
||||
(money/wei->str :eth (money/fee-value gas-used gas-price)))
|
||||
:url (transactions/get-transaction-details-url network hash)}))))))
|
||||
|
||||
(reg-sub :wallet.transactions.details/confirmations
|
||||
:<- [:wallet.transactions/transaction-details]
|
||||
(fn [transaction-details]
|
||||
:<- [:wallet.transactions/transaction-details]
|
||||
(fn [transaction-details]
|
||||
;;TODO (yenda) this field should be calculated based on the current-block and the block of the transaction
|
||||
(:confirmations transaction-details)))
|
||||
(:confirmations transaction-details)))
|
||||
|
||||
(reg-sub :wallet.transactions.details/confirmations-progress
|
||||
:<- [:wallet.transactions.details/confirmations]
|
||||
(fn [confirmations]
|
||||
(let [max-confirmations 10]
|
||||
(if (>= confirmations max-confirmations)
|
||||
100
|
||||
(* 100 (/ confirmations max-confirmations))))))
|
||||
:<- [:wallet.transactions.details/confirmations]
|
||||
(fn [confirmations]
|
||||
(let [max-confirmations 10]
|
||||
(if (>= confirmations max-confirmations)
|
||||
100
|
||||
(* 100 (/ confirmations max-confirmations))))))
|
||||
|
||||
(reg-sub :wallet.transactions/filters
|
||||
(fn [db]
|
||||
(get-in db [:wallet.transactions :filters])))
|
||||
(fn [db]
|
||||
(get-in db [:wallet.transactions :filters])))
|
||||
|
||||
(reg-sub :wallet.transactions/error-message?
|
||||
:<- [:wallet]
|
||||
(fn [wallet]
|
||||
(get-in wallet [:errors :transactions-update])))
|
||||
:<- [:wallet]
|
||||
(fn [wallet]
|
||||
(get-in wallet [:errors :transactions-update])))
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
(defn history-action [filter?]
|
||||
(cond->
|
||||
{:icon :icons/filter
|
||||
:icon-opts {:accessibility-label :filters-button}
|
||||
:handler #(re-frame/dispatch [:navigate-to-modal :wallet-transactions-filter])}
|
||||
{:icon :icons/filter
|
||||
:icon-opts {:accessibility-label :filters-button}
|
||||
:handler #(re-frame/dispatch [:navigate-to-modal :wallet-transactions-filter])}
|
||||
filter? (assoc-in [:icon-opts :overlay-style] styles/corner-dot)))
|
||||
|
||||
(defn- all-checked? [filter-data]
|
||||
|
|
Loading…
Reference in New Issue