Skip to content

Commit ff47ac5

Browse files
mohsen-ghafouribriansztamfater
authored andcommitted
[#21439] fix: close swap flow after confirmation
Signed-off-by: Brian Sztamfater <[email protected]>
1 parent 7e5df76 commit ff47ac5

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

src/status_im/contexts/wallet/swap/events.cljs

+14-8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
(fn [{:keys [db]} [{:keys [network asset-to-receive open-new-screen?] :as data}]]
1818
(let [{:keys [wallet]} db
1919
test-networks-enabled? (get-in db [:profile/profile :test-networks-enabled?])
20+
view-id (:view-id db)
2021
account (swap-utils/wallet-account wallet)
2122
asset-to-pay (if (get-in data [:asset-to-pay :networks])
2223
(:asset-to-pay data)
@@ -30,12 +31,13 @@
3031
{:db (-> db
3132
(assoc-in [:wallet :ui :swap :asset-to-pay] asset-to-pay)
3233
(assoc-in [:wallet :ui :swap :asset-to-receive] asset-to-receive)
33-
(assoc-in [:wallet :ui :swap :network] network'))
34+
(assoc-in [:wallet :ui :swap :network] network')
35+
(assoc-in [:wallet :ui :swap :launch-screen] view-id))
3436
:fx (if network'
3537
[[:dispatch [:wallet/switch-current-viewing-account (:address account)]]
3638
[:dispatch
3739
(if open-new-screen?
38-
[:navigate-to :screen/wallet.setup-swap]
40+
[:open-modal :screen/wallet.setup-swap]
3941
[:navigate-to-within-stack
4042
[:screen/wallet.setup-swap :screen/wallet.swap-select-asset-to-pay]])]
4143
[:dispatch [:wallet.swap/set-default-slippage]]]
@@ -204,12 +206,6 @@
204206
(fn [{:keys [db]}]
205207
{:db (update-in db [:wallet :ui] dissoc :swap)}))
206208

207-
(rf/reg-event-fx
208-
:wallet/on-swap-done
209-
(fn [_]
210-
{:fx [[:dispatch [:wallet/select-account-tab :activity]]
211-
[:dispatch [:wallet/clean-swap]]]}))
212-
213209
(rf/reg-event-fx :wallet/swap-transaction
214210
(fn [{:keys [db]} [sha3-pwd]]
215211
(let [wallet-address (get-in db
@@ -299,6 +295,7 @@
299295
:screen/wallet.swap-set-spending-cap
300296
:screen/wallet.swap-confirmation)])
301297
(when-not approval-required?
298+
(rf/dispatch [:wallet/end-swap-flow])
302299
(debounce/debounce-and-dispatch
303300
[:toasts/upsert
304301
{:id :swap-transaction-pending
@@ -424,3 +421,12 @@
424421
:last-request-uuid
425422
:approved-amount
426423
:approval-transaction-id)))})))
424+
425+
(rf/reg-event-fx :wallet/end-swap-flow
426+
(fn [{:keys [db]}]
427+
(let [launch-screen (get-in db [:wallet :ui :swap :launch-screen])
428+
address (get-in db [:wallet :current-viewing-account-address])]
429+
{:fx [(when (= launch-screen :wallet-stack)
430+
[:dispatch [:wallet/navigate-to-account-within-stack address]])
431+
[:dispatch [:wallet/fetch-activities-for-current-account]]
432+
[:dispatch [:wallet/select-account-tab :activity]]]})))

src/status_im/contexts/wallet/swap/setup_swap/view.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
:valid-input? valid-pay-input?
157157
:clean-approval-transaction? true}))
158158
[pay-input-amount])]
159-
(rn/use-unmount #(rf/dispatch [:wallet/on-swap-done]))
159+
(rn/use-unmount #(rf/dispatch [:wallet/clean-swap]))
160160
(rn/use-effect
161161
(fn []
162162
(request-fetch-swap-proposal))

src/status_im/navigation/screens.cljs

+2-1
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,8 @@
535535
:component wallet-swap-select-asset-to-pay/view}
536536

537537
{:name :screen/wallet.setup-swap
538-
:options {:insets {:bottom? true}}
538+
:options {:modalPresentationStyle :overCurrentContext
539+
:insets {:bottom? true}}
539540
:component wallet-swap-setup-swap/view}
540541

541542
{:name :screen/wallet.swap-propasal

0 commit comments

Comments
 (0)