Properly clearing `[:wallet :send-transaction]`

This PR fixes the fact, that `[:wallet :send-transaction]` path
in db was not properly cleared in some cases, which demonstrated
as couple of the subtle issues (like that you were taken straight
to the signing state on tx-modal in when sending `/send` command
and some tx was sent previously from wallet, and some quite serious,
like #2197, which was caused by password info not properly cleared
between multiple invocations of the `/send` command.
This commit is contained in:
janherich 2017-10-17 19:10:54 +02:00 committed by Roman Volosovskyi
parent 22f39e88c0
commit 4062eed675
1 changed files with 9 additions and 9 deletions

View File

@ -38,15 +38,15 @@
:gas-price (money/to-decimal gasPrice)
:timestamp now
:message-id message_id}
sending-from-chat? (not (get-in db [:wallet :send-transaction :waiting-signal?]))]
(merge
{:db (-> db
(assoc-in [:wallet :transactions-unsigned id] transaction)
(assoc-in [:wallet :send-transaction :id] id)
(assoc-in [:wallet :send-transaction :from-chat?] sending-from-chat?))}
(if sending-from-chat?
{:dispatch [:navigate-to-modal :wallet-send-transaction-modal]}
{:dispatch [:wallet.send-transaction/transaction-queued id]})))
sending-from-chat? (not (get-in db [:wallet :send-transaction :waiting-signal?]))
new-db (assoc-in db [:wallet :transactions-unsigned id] transaction)
sending-db {:id id
:from-chat? sending-from-chat?}]
(if sending-from-chat?
{:db (assoc-in new-db [:wallet :send-transaction] sending-db) ; we need to completly reset sending state here
:dispatch [:navigate-to-modal :wallet-send-transaction-modal]}
{:db (update-in new-db [:wallet :send-transaction] merge sending-db) ; just update sending state as we are in wallet flow
:dispatch [:wallet.send-transaction/transaction-queued id]}))
{:discard-transaction id})))
;;TRANSACTION FAILED signal from status-go