fix_: Adding own address as saved addresses (#20839)
This commit: - prevents the user from saving their wallet address as the saved address - fixes button not capturing taps when the keyboard is open in saved address flows Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>
This commit is contained in:
parent
c6a63e30b2
commit
4989c92780
|
@ -7,6 +7,7 @@
|
||||||
[react-native.safe-area :as safe-area]
|
[react-native.safe-area :as safe-area]
|
||||||
[status-im.common.floating-button-page.view :as floating-button-page]
|
[status-im.common.floating-button-page.view :as floating-button-page]
|
||||||
[status-im.contexts.settings.wallet.saved-addresses.add-address-to-save.style :as style]
|
[status-im.contexts.settings.wallet.saved-addresses.add-address-to-save.style :as style]
|
||||||
|
[status-im.contexts.wallet.common.utils :as utils]
|
||||||
[status-im.contexts.wallet.common.validation :as validation]
|
[status-im.contexts.wallet.common.validation :as validation]
|
||||||
[utils.debounce :as debounce]
|
[utils.debounce :as debounce]
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
|
@ -18,20 +19,21 @@
|
||||||
|
|
||||||
(defn- validate-input
|
(defn- validate-input
|
||||||
[account-addresses saved-addresses user-input]
|
[account-addresses saved-addresses user-input]
|
||||||
(cond
|
(let [[_ address-without-prefix] (utils/split-prefix-and-address user-input)]
|
||||||
(string/blank? user-input)
|
(cond
|
||||||
nil
|
(string/blank? user-input)
|
||||||
|
nil
|
||||||
|
|
||||||
(contains? saved-addresses user-input)
|
(contains? saved-addresses address-without-prefix)
|
||||||
:existing-saved-address
|
:existing-saved-address
|
||||||
|
|
||||||
(contains? account-addresses user-input)
|
(contains? account-addresses address-without-prefix)
|
||||||
:own-account
|
:own-account
|
||||||
|
|
||||||
(not
|
(not
|
||||||
(or (validation/eth-address? user-input)
|
(or (validation/eth-address? user-input)
|
||||||
(validation/ens-name? user-input)))
|
(validation/ens-name? user-input)))
|
||||||
:invalid-address-or-ens))
|
:invalid-address-or-ens)))
|
||||||
|
|
||||||
(defn- address-input
|
(defn- address-input
|
||||||
[{:keys [input-value on-change-text paste-into-input clear-input]}]
|
[{:keys [input-value on-change-text paste-into-input clear-input]}]
|
||||||
|
@ -93,8 +95,9 @@
|
||||||
|
|
||||||
(defn- existing-saved-address
|
(defn- existing-saved-address
|
||||||
[{:keys [address]}]
|
[{:keys [address]}]
|
||||||
(let [{:keys [name customization-color chain-short-names ens ens?]}
|
(let [[_ address-without-prefix] (utils/split-prefix-and-address address)
|
||||||
(rf/sub [:wallet/saved-address-by-address address])]
|
{:keys [name customization-color chain-short-names ens ens?]}
|
||||||
|
(rf/sub [:wallet/saved-address-by-address address-without-prefix])]
|
||||||
[rn/view {:style style/existing-saved-address-container}
|
[rn/view {:style style/existing-saved-address-container}
|
||||||
[quo/text
|
[quo/text
|
||||||
{:size :paragraph-1
|
{:size :paragraph-1
|
||||||
|
@ -105,7 +108,7 @@
|
||||||
{:blur? true
|
{:blur? true
|
||||||
:active-state? true
|
:active-state? true
|
||||||
:user-props {:name name
|
:user-props {:name name
|
||||||
:address (str chain-short-names address)
|
:address (str chain-short-names address-without-prefix)
|
||||||
:ens (when ens? ens)
|
:ens (when ens? ens)
|
||||||
:customization-color customization-color
|
:customization-color customization-color
|
||||||
:blur? true}
|
:blur? true}
|
||||||
|
@ -168,20 +171,21 @@
|
||||||
(rn/use-mount #(rf/dispatch [:wallet/clear-address-to-save]))
|
(rn/use-mount #(rf/dispatch [:wallet/clear-address-to-save]))
|
||||||
[quo/overlay {:type :shell}
|
[quo/overlay {:type :shell}
|
||||||
[floating-button-page/view
|
[floating-button-page/view
|
||||||
{:footer-container-padding 0
|
{:footer-container-padding 0
|
||||||
:header [quo/page-nav
|
:keyboard-should-persist-taps :handled
|
||||||
{:type :no-title
|
:header [quo/page-nav
|
||||||
:icon-name :i/close
|
{:type :no-title
|
||||||
:behind-overlay? true
|
:icon-name :i/close
|
||||||
:on-press navigate-back
|
:behind-overlay? true
|
||||||
:margin-top (safe-area/get-top)
|
:on-press navigate-back
|
||||||
:accessibility-label :add-address-to-save-page-nav}]
|
:margin-top (safe-area/get-top)
|
||||||
:footer (when (= view-id :screen/settings.add-address-to-save)
|
:accessibility-label :add-address-to-save-page-nav}]
|
||||||
[quo/button
|
:footer (when (= view-id :screen/settings.add-address-to-save)
|
||||||
{:customization-color profile-color
|
[quo/button
|
||||||
:disabled? button-disabled?
|
{:customization-color profile-color
|
||||||
:on-press on-press-continue}
|
:disabled? button-disabled?
|
||||||
(i18n/label :t/continue)])}
|
:on-press on-press-continue}
|
||||||
|
(i18n/label :t/continue)])}
|
||||||
[quo/page-top
|
[quo/page-top
|
||||||
{:container-style style/header-container
|
{:container-style style/header-container
|
||||||
:blur? true
|
:blur? true
|
||||||
|
|
|
@ -105,24 +105,25 @@
|
||||||
[ens ens? open-network-preferences address-text])]
|
[ens ens? open-network-preferences address-text])]
|
||||||
[quo/overlay {:type :shell}
|
[quo/overlay {:type :shell}
|
||||||
[floating-button-page/view
|
[floating-button-page/view
|
||||||
{:footer-container-padding (if edit? (+ (safe-area/get-bottom) 12) 0)
|
{:footer-container-padding (if edit? (+ (safe-area/get-bottom) 12) 0)
|
||||||
:header [quo/page-nav
|
:keyboard-should-persist-taps :handled
|
||||||
{:type :no-title
|
:header [quo/page-nav
|
||||||
:background :blur
|
{:type :no-title
|
||||||
:icon-name (if edit? :i/close :i/arrow-left)
|
:background :blur
|
||||||
:on-press navigate-back
|
:icon-name (if edit? :i/close :i/arrow-left)
|
||||||
:margin-top (when-not edit? (safe-area/get-top))
|
:on-press navigate-back
|
||||||
:accessibility-label :save-address-page-nav}]
|
:margin-top (when-not edit? (safe-area/get-top))
|
||||||
:footer [quo/button
|
:accessibility-label :save-address-page-nav}]
|
||||||
{:accessibility-label :save-address-button
|
:footer [quo/button
|
||||||
:type :primary
|
{:accessibility-label :save-address-button
|
||||||
:customization-color address-color
|
:type :primary
|
||||||
:disabled? (string/blank? address-label)
|
:customization-color address-color
|
||||||
:on-press on-press-save}
|
:disabled? (string/blank? address-label)
|
||||||
(i18n/label :t/save-address)]
|
:on-press on-press-save}
|
||||||
:customization-color address-color
|
(i18n/label :t/save-address)]
|
||||||
:gradient-cover? true
|
:customization-color address-color
|
||||||
:shell-overlay? true}
|
:gradient-cover? true
|
||||||
|
:shell-overlay? true}
|
||||||
[quo/wallet-user-avatar
|
[quo/wallet-user-avatar
|
||||||
{:full-name (if (string/blank? address-label)
|
{:full-name (if (string/blank? address-label)
|
||||||
placeholder
|
placeholder
|
||||||
|
|
Loading…
Reference in New Issue