fix: clean up state after unmounting (#21435)

This commit is contained in:
Lungu Cristian 2024-10-16 10:57:01 +03:00 committed by GitHub
parent 3c55fc1fa2
commit 6a26ebafa3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View File

@ -204,6 +204,12 @@
(fn [{:keys [db]}] (fn [{:keys [db]}]
{:db (update-in db [:wallet :ui] dissoc :swap)})) {:db (update-in db [:wallet :ui] dissoc :swap)}))
(rf/reg-event-fx
:wallet/on-swap-done
(fn [_]
{:fx [[:dispatch [:wallet/select-account-tab :activity]]
[:dispatch [:wallet/clean-swap]]]}))
(rf/reg-event-fx :wallet/swap-transaction (rf/reg-event-fx :wallet/swap-transaction
(fn [{:keys [db]} [sha3-pwd]] (fn [{:keys [db]} [sha3-pwd]]
(let [wallet-address (get-in db (let [wallet-address (get-in db
@ -298,8 +304,6 @@
:screen/wallet.swap-set-spending-cap :screen/wallet.swap-set-spending-cap
:screen/wallet.swap-confirmation)]) :screen/wallet.swap-confirmation)])
(when-not approval-required? (when-not approval-required?
(rf/dispatch [:wallet/select-account-tab :activity])
(rf/dispatch [:wallet/clean-swap])
(debounce/debounce-and-dispatch (debounce/debounce-and-dispatch
[:toasts/upsert [:toasts/upsert
{:id :swap-transaction-pending {:id :swap-transaction-pending

View File

@ -148,6 +148,7 @@
:valid-input? valid-pay-input? :valid-input? valid-pay-input?
:clean-approval-transaction? true})) :clean-approval-transaction? true}))
[pay-input-amount])] [pay-input-amount])]
(rn/use-unmount #(rf/dispatch [:wallet/on-swap-done]))
(rn/use-effect (rn/use-effect
(fn [] (fn []
(request-fetch-swap-proposal)) (request-fetch-swap-proposal))