fix: dont dismiss modal on drag down

This commit is contained in:
Lungu Cristian 2024-07-25 10:47:29 +03:00
parent fd9979d2ef
commit 9fd2ebdfec
No known key found for this signature in database
GPG Key ID: 3BFFC98CA928FC4F
1 changed files with 11 additions and 5 deletions

View File

@ -99,7 +99,7 @@
(rf/reg-event-fx (rf/reg-event-fx
:wallet-connect/send-response :wallet-connect/send-response
(fn [{:keys [db]} [{:keys [result error]}]] (fn [{:keys [db]} [{:keys [result error no-dismiss-modal?]}]]
(when-let [{:keys [id topic] :as event} (get-in db [:wallet-connect/current-request :event])] (when-let [{:keys [id topic] :as event} (get-in db [:wallet-connect/current-request :event])]
(let [method (wallet-connect-core/get-request-method event) (let [method (wallet-connect-core/get-request-method event)
screen (wallet-connect-core/method-to-screen method) screen (wallet-connect-core/method-to-screen method)
@ -117,10 +117,15 @@
:method method :method method
:event :wallet-connect/send-response :event :wallet-connect/send-response
:wallet-connect-event event}) :wallet-connect-event event})
(rf/dispatch [:dismiss-modal screen])) ;; FIXME(@clauxx): this is no good and we should fix it ASAP. IMO the
;; dispatcher of send-response should be responsible for success/error
;; behavior, including dismissing the modal. The flag ugly as hell.
(when-not no-dismiss-modal?
(rf/dispatch [:dismiss-modal screen])))
:on-success (fn [] :on-success (fn []
(log/info "Successfully sent Wallet Connect response to dApp") (log/info "Successfully sent Wallet Connect response to dApp")
(rf/dispatch [:dismiss-modal screen]))}]]})))) (when-not no-dismiss-modal?
(rf/dispatch [:dismiss-modal screen])))}]]}))))
(rf/reg-event-fx (rf/reg-event-fx
:wallet-connect/dismiss-request-modal :wallet-connect/dismiss-request-modal
@ -164,6 +169,7 @@
{:fx [(when-not (get-in db [:wallet-connect/current-request :response-sent?]) {:fx [(when-not (get-in db [:wallet-connect/current-request :response-sent?])
[:dispatch [:dispatch
[:wallet-connect/send-response [:wallet-connect/send-response
{:error (wallet-connect/get-sdk-error {:error (wallet-connect/get-sdk-error
constants/wallet-connect-user-rejected-error-key)}]]) constants/wallet-connect-user-rejected-error-key)
:no-dismiss-modal? true}]])
[:dispatch [:wallet-connect/reset-current-request]]]})) [:dispatch [:wallet-connect/reset-current-request]]]}))