Fix auth slider resetting when wallet connect signing is finished (#20589)

* Fix auth slider resetting when wallet connect signing is finished

* Lint fix

* Fixes

* Fixes
This commit is contained in:
Alexander 2024-07-03 15:27:27 +02:00 committed by GitHub
parent 2e8776d0a6
commit 35a1905396
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 52 additions and 37 deletions

View File

@ -26,7 +26,8 @@
(reanimated/set-shared-value x-pos clamped-x)
(when (and reached-end? (not sliding-complete?))
(set-sliding-complete true)
(when on-complete (on-complete reset-fn))))))
(when on-complete
(on-complete reset-fn))))))
(gesture/on-end (fn [event]
(let [x-translation (oops/oget event "translationX")
reached-end? (>= x-translation track-width)]
@ -54,9 +55,10 @@
on-track-layout (rn/use-callback
#(set-track-width (oops/oget % "nativeEvent.layout.width")))
reset-fn (rn/use-callback
(fn []
(fn [keep-at-end-after-slide?]
(set-sliding-complete false)
(animations/reset-track-position x-pos)))
(when-not keep-at-end-after-slide?
(animations/reset-track-position x-pos))))
dimensions (rn/use-callback
(partial utils/get-dimensions
(or track-width constants/default-width)

View File

@ -32,9 +32,8 @@
:on-cancel #(rf/dispatch [:standard-auth/authorize-with-password
args-with-biometric-btn])
:on-success (fn []
(when (fn? on-close)
(on-close))
(rf/dispatch [:standard-auth/on-biometric-success on-auth-success]))
(rf/dispatch [:standard-auth/on-biometric-success on-auth-success])
(rf/dispatch [:standard-auth/close on-close]))
:on-fail (fn [err]
(rf/dispatch [:standard-auth/authorize-with-password
args-with-biometric-btn])
@ -48,6 +47,7 @@
[{:keys [db]} [on-auth-success]]
(let [key-uid (get-in db [:profile/profile :key-uid])]
{:fx [[:keychain/get-user-password [key-uid on-auth-success]]
[:dispatch [:standard-auth/set-success true]]
[:dispatch [:standard-auth/reset-login-password]]]}))
(schema/=> on-biometric-success events-schema/?on-biometric-success)
@ -74,6 +74,7 @@
(fn [password]
(let [sha3-pwd (security/hash-masked-password password)
on-auth-success-callback #(on-auth-success sha3-pwd)]
(rf/dispatch [:standard-auth/set-success true])
(rf/dispatch [:standard-auth/reset-login-password])
(if has-partially-operable-accounts?
(rf/dispatch [:wallet/make-partially-operable-accounts-fully-operable
@ -92,10 +93,7 @@
{:fx [[:dispatch [:standard-auth/reset-login-password]]
[:dispatch
[:show-bottom-sheet
{:on-close (fn []
(rf/dispatch [:standard-auth/reset-login-password])
(when on-close
(on-close)))
{:on-close #(rf/dispatch [:standard-auth/close on-close])
:theme theme
:shell? blur?
:content #(bottom-sheet-password-view args)}]]]})
@ -107,3 +105,23 @@
:standard-auth/reset-login-password
(fn [{:keys [db]}]
{:db (update db :profile/login dissoc :password :error)}))
(rf/reg-fx
:standard-auth/on-close
(fn [{:keys [on-close success?]}]
(when on-close
(on-close success?))))
(rf/reg-event-fx
:standard-auth/close
(fn [{:keys [db]} [on-close]]
{:db (assoc-in db [:profile/login :success?] false)
:fx [[:dispatch [:standard-auth/reset-login-password]]
[:standard-auth/on-close
{:on-close on-close
:success? (get-in db [:profile/login :success?])}]]}))
(rf/reg-event-fx
:standard-auth/set-success
(fn [{:keys [db]} [success?]]
{:db (assoc-in db [:profile/login :success?] success?)}))

View File

@ -16,7 +16,8 @@
on-complete (rn/use-callback
(fn [reset]
(rf/dispatch [:standard-auth/authorize
{:on-close #(js/setTimeout reset 200)
{:on-close (fn [success?]
(js/setTimeout #(reset success?) 200))
:auth-button-icon-left auth-button-icon-left
:theme theme
:blur? blur?

View File

@ -1,7 +1,6 @@
(ns status-im.contexts.preview.quo.buttons.slide-button
(:require
[quo.core :as quo]
[react-native.core :as rn]
[reagent.core :as reagent]
[status-im.contexts.preview.quo.preview :as preview]))
@ -18,41 +17,36 @@
:type :boolean}
{:key :blur?
:type :boolean}
{:key :keep-at-end-after-slide?
:type :boolean}
(preview/customization-color-option {:key :color})])
(defn f-view
[]
(let [state (reagent/atom {:disabled? false
:color :blue
:size :size-48})
color (reagent/cursor state [:color])
blur? (reagent/cursor state [:blur?])
complete? (reagent/atom false)]
(let [state (reagent/atom {:disabled? false
:color :blue
:size :size-48
:keep-at-end-after-slide? false})
color (reagent/cursor state [:color])
blur? (reagent/cursor state [:blur?])
keep-at-end-after-slide? (reagent/cursor state [:keep-at-end-after-slide?])]
(fn []
(rn/use-effect (fn []
(reset! complete? true)
(js/setTimeout #(reset! complete? false) 50))
[(:size @state)])
[preview/preview-container
{:state state
:descriptor descriptor
:component-container-style (when-not @blur? (:align-items :center))
:blur? @blur?
:show-blur-background? true}
(if (not @complete?)
[quo/slide-button
{:track-text "We gotta slide"
:track-icon :face-id
:customization-color @color
:size (:size @state)
:disabled? (:disabled? @state)
:blur? @blur?
:type (:type @state)
:on-complete (fn [_]
(js/setTimeout (fn [] (reset! complete? true))
1000)
(js/alert "I don't wanna slide anymore"))}]
[quo/button {:on-press (fn [] (reset! complete? false))}
"Try again"])])))
[quo/slide-button
{:track-text "We gotta slide"
:track-icon :face-id
:customization-color @color
:size (:size @state)
:disabled? (:disabled? @state)
:blur? @blur?
:type (:type @state)
:on-complete (fn [reset-fn]
(js/alert "Slide complete")
(reset-fn @keep-at-end-after-slide?))}]])))
(defn view [] [:f> f-view])