Add loading spinner logic to transaction-modal

Block screen while signing

Move threaded assocs into an update

Add assoc
This commit is contained in:
angusiguess 2017-10-09 11:21:56 -03:00 committed by Roman Volosovskyi
parent 91e6de1286
commit 78d76292e1
2 changed files with 13 additions and 7 deletions

View File

@ -61,12 +61,16 @@
(handlers/register-handler-fx (handlers/register-handler-fx
::transaction-modal-completed ::transaction-modal-completed
(fn [{db :db} [_ {:keys [id response]}]] (fn [{db :db} [_ {:keys [id response]}]]
(let [{:keys [hash error]} response] (let [{:keys [hash error]} response
(when-not (and error (string? error) (not (string/blank? error))) db' (assoc-in db [:wallet/send-transaction :in-progress?] false)
{:db (-> db has-error? (and error (string? error) (not (string/blank? error)))]
(if has-error?
{:db db'}
{:db (-> db'
(update-in [:wallet :transactions-unsigned] dissoc id) (update-in [:wallet :transactions-unsigned] dissoc id)
(assoc-in [:wallet/send-transaction :transaction-id] nil) (update :wallet/send-transaction assoc
(assoc-in [:wallet/send-transaction :wrong-password?] false)) :transaction-id nil
:wrong-password? false))
:dispatch [:navigate-back]})))) :dispatch [:navigate-back]}))))
(defn on-transactions-modal-completed [raw-results] (defn on-transactions-modal-completed [raw-results]
@ -114,7 +118,8 @@
:accounts/keys [accounts current-account-id] :as db} :db} [_ later?]] :accounts/keys [accounts current-account-id] :as db} :db} [_ later?]]
(let [{:keys [amount transaction-id password]} send-transaction (let [{:keys [amount transaction-id password]} send-transaction
amount' (money/to-wei (string/replace amount #"," "."))] amount' (money/to-wei (string/replace amount #"," "."))]
{::accept-transaction {:id transaction-id {:db (assoc-in db [:wallet/send-transaction :in-progress?] true)
::accept-transaction {:id transaction-id
:password password :password password
:on-completed on-transactions-modal-completed}}))) :on-completed on-transactions-modal-completed}})))

View File

@ -182,4 +182,5 @@
in-progress?] in-progress?]
[sign-buttons amount-error to-address amount true #(re-frame/dispatch [:navigate-back])]) [sign-buttons amount-error to-address amount true #(re-frame/dispatch [:navigate-back])])
(when signing? (when signing?
[sign-panel])]])) [sign-panel])]
(when in-progress? [react/view send.styles/processing-view])]))