From 4062eed675c3ec178fe5aace532a7f4fa515cdbd Mon Sep 17 00:00:00 2001 From: janherich Date: Tue, 17 Oct 2017 19:10:54 +0200 Subject: [PATCH] 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. --- .../ui/screens/wallet/transactions/events.cljs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/status_im/ui/screens/wallet/transactions/events.cljs b/src/status_im/ui/screens/wallet/transactions/events.cljs index ef3d937a96..66f71e8477 100644 --- a/src/status_im/ui/screens/wallet/transactions/events.cljs +++ b/src/status_im/ui/screens/wallet/transactions/events.cljs @@ -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