Skip to content

Commit

Permalink
fix: debounce password input
Browse files Browse the repository at this point in the history
Signed-off-by: yqrashawn <namy.19@gmail.com>
  • Loading branch information
yqrashawn committed Feb 6, 2024
1 parent 2e7a9c8 commit 27d1f63
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[react-native.core :as rn]
[status-im.common.standard-authentication.forgot-password-doc.view :as forgot-password-doc]
[status-im.common.standard-authentication.password-input.style :as style]
[utils.debounce :as debounce]
[utils.i18n :as i18n]
[utils.re-frame :as rf]
[utils.security.core :as security]))
Expand All @@ -22,8 +23,9 @@

(defn- on-change-password
[entered-password]
(rf/dispatch [:set-in [:profile/login :password]
(security/mask-data entered-password)])
(debounce/debounce-and-dispatch [:set-in [:profile/login :password]
(security/mask-data entered-password)]
100)
(rf/dispatch [:set-in [:profile/login :error] ""]))

(defn- view-internal
Expand Down
33 changes: 19 additions & 14 deletions src/status_im/contexts/profile/profiles/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,29 @@
[props]
[:f> f-profiles-section props])

(defn password-input
[]
(let [password (rf/sub [:profile/login-password])
auth-method (rf/sub [:auth-method])]
[standard-authentication/password-input
{:shell? true
:blur? true
:on-press-biometrics (when (= auth-method constants/auth-method-biometric)
(fn []
(rf/dispatch [:biometric/authenticate
{:on-success #(rf/dispatch
[:profile.login/biometric-success])
:on-fail #(rf/dispatch
[:profile.login/biometric-auth-fail
%])}])))
:default-password (log/spy :info password)}]))

(defn login-section
[{:keys [set-show-profiles]}]
(let [{:keys [processing password]} (rf/sub [:profile/login])
(let [processing (rf/sub [:profile/login-processing])
{:keys [key-uid name customization-color]} (rf/sub [:profile/login-profile])
sign-in-enabled? (rf/sub [:sign-in-enabled?])
profile-picture (rf/sub [:profile/login-profiles-picture key-uid])
auth-method (rf/sub [:auth-method])
login-multiaccount #(rf/dispatch [:profile.login/login])]
[rn/keyboard-avoiding-view
{:style style/login-container
Expand Down Expand Up @@ -213,18 +229,7 @@
:customization-color (or customization-color :primary)
:profile-picture profile-picture
:card-style style/login-profile-card}]
[standard-authentication/password-input
{:shell? true
:blur? true
:on-press-biometrics (when (= auth-method constants/auth-method-biometric)
(fn []
(rf/dispatch [:biometric/authenticate
{:on-success #(rf/dispatch
[:profile.login/biometric-success])
:on-fail #(rf/dispatch
[:profile.login/biometric-auth-fail
%])}])))
:default-password password}]]
[password-input]]
[quo/button
{:size 40
:type :primary
Expand Down
12 changes: 12 additions & 0 deletions src/status_im/subs/profile.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,18 @@
(fn [[{:keys [key-uid]} profiles]]
(get profiles key-uid)))

(re-frame/reg-sub
:profile/login-processing
:<- [:profile/login]
(fn [{:keys [processing]}]
processing))

(re-frame/reg-sub
:profile/login-password
:<- [:profile/login]
(fn [{:keys [password]}]
password))

;; LINK PREVIEW
;; ========================================================================================================

Expand Down

0 comments on commit 27d1f63

Please sign in to comment.