mirror of
https://github.com/status-im/status-mobile.git
synced 2025-01-27 08:55:39 +00:00
fix: ENS regex not being used to detect an ENS on address input (#18626)
Signed-off-by: Brian Sztamfater <brian@status.im>
This commit is contained in:
parent
c70646bd5c
commit
ae7ee33f00
@ -61,24 +61,30 @@
|
||||
value (reagent/atom "")
|
||||
focused? (atom false)]
|
||||
(fn [{:keys [scanned-value theme blur? on-change-text on-blur on-focus on-clear on-scan
|
||||
on-detect-ens on-detect-address address-regex valid-ens-or-address?
|
||||
container-style]}]
|
||||
on-detect-ens on-detect-address on-detect-unclassified address-regex ens-regex
|
||||
valid-ens-or-address? container-style]}]
|
||||
(let [on-change (fn [text]
|
||||
(when (not= @value text)
|
||||
(let [address? (when address-regex
|
||||
(boolean (re-matches address-regex text)))]
|
||||
(boolean (re-matches address-regex text)))
|
||||
ens? (when ens-regex
|
||||
(boolean (re-matches ens-regex text)))]
|
||||
(if (> (count text) 0)
|
||||
(reset! status :typing)
|
||||
(reset! status :active))
|
||||
(reset! value text)
|
||||
(when on-change-text
|
||||
(on-change-text text))
|
||||
(when (and on-detect-ens (> (count text) 0))
|
||||
(when (and on-detect-ens ens?)
|
||||
(reset! status :loading)
|
||||
(on-detect-ens text #(reset! status :typing)))
|
||||
(when (and address? on-detect-address)
|
||||
(reset! status :loading)
|
||||
(on-detect-address text)))))
|
||||
(on-detect-address text))
|
||||
(when (and (not address?)
|
||||
(not ens?)
|
||||
on-detect-unclassified)
|
||||
(on-detect-unclassified text)))))
|
||||
on-paste (fn []
|
||||
(clipboard/get-string
|
||||
(fn [clipboard]
|
||||
|
@ -313,6 +313,10 @@
|
||||
(background-timer/clear-timeout current-timeout)
|
||||
{:db (assoc db :wallet/local-suggestions [] :wallet/valid-ens-or-address? false)})))
|
||||
|
||||
(rf/reg-event-fx :wallet/clean-ens-or-address-validation
|
||||
(fn [{:keys [db]}]
|
||||
{:db (assoc db :wallet/valid-ens-or-address? false)}))
|
||||
|
||||
(rf/reg-event-fx :wallet/get-address-details-success
|
||||
(fn [{:keys [db]} [{:keys [hasActivity]}]]
|
||||
{:db (assoc-in db
|
||||
|
@ -48,6 +48,8 @@
|
||||
(debounce/debounce-and-dispatch
|
||||
[:wallet/find-ens text contacts chain-id cb]
|
||||
300))
|
||||
:on-detect-unclassified #(when valid-ens-or-address?
|
||||
(rf/dispatch [:wallet/clean-ens-or-address-validation]))
|
||||
:on-change-text (fn [text]
|
||||
(when (empty? text)
|
||||
(rf/dispatch [:wallet/clean-local-suggestions]))
|
||||
|
Loading…
x
Reference in New Issue
Block a user