This commit is contained in:
Gustavo Nunes 2017-05-24 02:01:32 -03:00 committed by Roman Volosovskyi
parent 1b2f657bfb
commit dd976fb2af
1 changed files with 16 additions and 13 deletions

View File

@ -4,7 +4,7 @@
[status-im.navigation.handlers :as nav] [status-im.navigation.handlers :as nav]
[status-im.utils.handlers :as u] [status-im.utils.handlers :as u]
[status-im.utils.types :as t] [status-im.utils.types :as t]
[status-im.utils.hex :refer [valid-hex?]] [status-im.utils.hex :refer [valid-hex? normalize-hex]]
[status-im.components.status :as status] [status-im.components.status :as status]
[clojure.string :as s] [clojure.string :as s]
[taoensso.timbre :as log])) [taoensso.timbre :as log]))
@ -189,21 +189,24 @@
(register-handler :transaction-failed (register-handler :transaction-failed
(u/side-effect! (u/side-effect!
(fn [_ [_ {:keys [id message_id error_code error_message] :as event}]] (fn [{:keys [current-account-id accounts]} [_ {:keys [id args message_id error_code error_message] :as event}]]
(cond (let [current-account-address (:address (get accounts current-account-id))
transaction-initiator-address (normalize-hex (:from args))]
(cond
(= error_code wrong-password-code) (= error_code wrong-password-code)
(dispatch [:set-wrong-password!]) (dispatch [:set-wrong-password!])
(not= discard-code error_code) (not= discard-code error_code)
(do (when message_id (do (when message_id
(dispatch [::remove-pending-message message_id])) (dispatch [::remove-pending-message message_id]))
(dispatch [:clear-selected-transaction]) (dispatch [:clear-selected-transaction])
(dispatch [::remove-transaction id]) (dispatch [::remove-transaction id])
(dispatch [:set-chat-ui-props {:validation-messages error_message}])) (when (= current-account-address transaction-initiator-address)
(dispatch [:set-chat-ui-props {:validation-messages error_message}])))
:else :else
(dispatch [:set-chat-ui-props {:validation-messages nil}]))))) (dispatch [:set-chat-ui-props {:validation-messages nil}]))))))
(register-handler :clear-selected-transaction (register-handler :clear-selected-transaction
(fn [db _] (fn [db _]