fix nickname not setted on adding contact (#13341)
* fix nickname not setted on adding contact * QA changes
This commit is contained in:
parent
81a8ed95a7
commit
b1606704f7
|
@ -68,7 +68,7 @@
|
||||||
|
|
||||||
(fx/defn qr-code-handled
|
(fx/defn qr-code-handled
|
||||||
{:events [::qr-code-handled]}
|
{:events [::qr-code-handled]}
|
||||||
[{:keys [db] :as cofx} {:keys [type public-key chat-id data ens-name]} {:keys [new-contact?] :as opts}]
|
[{:keys [db] :as cofx} {:keys [type public-key chat-id data ens-name]} {:keys [new-contact? nickname] :as opts}]
|
||||||
(let [public-key? (and (string? data)
|
(let [public-key? (and (string? data)
|
||||||
(string/starts-with? data "0x"))
|
(string/starts-with? data "0x"))
|
||||||
chat-key (cond
|
chat-key (cond
|
||||||
|
@ -80,7 +80,7 @@
|
||||||
(if-not validation-result
|
(if-not validation-result
|
||||||
(if new-contact?
|
(if new-contact?
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
(contact/add-contact chat-key nil ens-name)
|
(contact/add-contact chat-key nickname ens-name)
|
||||||
(navigation/navigate-to-cofx :contacts-list {}))
|
(navigation/navigate-to-cofx :contacts-list {}))
|
||||||
(chat/start-chat cofx chat-key ens-name))
|
(chat/start-chat cofx chat-key ens-name))
|
||||||
{:utils/show-popup {:title (i18n/label :t/unable-to-read-this-code)
|
{:utils/show-popup {:title (i18n/label :t/unable-to-read-this-code)
|
||||||
|
|
|
@ -254,58 +254,59 @@
|
||||||
:auto-correct false}])
|
:auto-correct false}])
|
||||||
|
|
||||||
(defn new-contact []
|
(defn new-contact []
|
||||||
(let [{:keys [state ens-name public-key error]} @(re-frame/subscribe [:contacts/new-identity])
|
(let [entered-nickname (reagent/atom "")]
|
||||||
entered-nickname (reagent/atom "")
|
(fn []
|
||||||
blocked? (and
|
(let [{:keys [state ens-name public-key error]} @(re-frame/subscribe [:contacts/new-identity])
|
||||||
(utils.db/valid-public-key? (or public-key ""))
|
blocked? (and
|
||||||
@(re-frame/subscribe [:contacts/contact-blocked? public-key]))]
|
(utils.db/valid-public-key? (or public-key ""))
|
||||||
[react/view {:style {:flex 1}}
|
@(re-frame/subscribe [:contacts/contact-blocked? public-key]))]
|
||||||
[topbar/topbar
|
[react/view {:style {:flex 1}}
|
||||||
{:title (i18n/label :t/new-contact)
|
[topbar/topbar
|
||||||
:modal? true
|
{:title (i18n/label :t/new-contact)
|
||||||
:right-accessories
|
:modal? true
|
||||||
[{:icon :qr
|
:right-accessories
|
||||||
:accessibility-label :scan-contact-code-button
|
[{:icon :qr
|
||||||
:on-press #(re-frame/dispatch [::qr-scanner/scan-code
|
:accessibility-label :scan-contact-code-button
|
||||||
{:title (i18n/label :t/new-contact)
|
:on-press #(re-frame/dispatch [::qr-scanner/scan-code
|
||||||
:handler :contact/qr-code-scanned
|
{:title (i18n/label :t/new-contact)
|
||||||
:new-contact? true}])}]}]
|
:handler :contact/qr-code-scanned
|
||||||
[react/view {:flex-direction :row
|
:new-contact? true
|
||||||
:padding 16}
|
:nickname @entered-nickname}])}]}]
|
||||||
[react/view {:flex 1
|
[react/view {:flex-direction :row
|
||||||
:padding-right 16}
|
:padding 16}
|
||||||
[quo/text-input
|
[react/view {:flex 1
|
||||||
{:on-change-text
|
:padding-right 16}
|
||||||
#(do
|
[quo/text-input
|
||||||
(re-frame/dispatch [:set-in [:contacts/new-identity :state] :searching])
|
{:on-change-text
|
||||||
(debounce/debounce-and-dispatch [:new-chat/set-new-identity %] 600))
|
#(do
|
||||||
:on-submit-editing
|
(re-frame/dispatch [:set-in [:contacts/new-identity :state] :searching])
|
||||||
#(when (= state :valid)
|
(debounce/debounce-and-dispatch [:new-chat/set-new-identity %] 600))
|
||||||
(debounce/dispatch-and-chill [:contact.ui/contact-code-submitted true @entered-nickname] 3000))
|
:on-submit-editing
|
||||||
:placeholder (i18n/label :t/enter-contact-code)
|
#(when (= state :valid)
|
||||||
:show-cancel false
|
(debounce/dispatch-and-chill [:contact.ui/contact-code-submitted true @entered-nickname] 3000))
|
||||||
:accessibility-label :enter-contact-code-input
|
:placeholder (i18n/label :t/enter-contact-code)
|
||||||
:auto-capitalize :none
|
:show-cancel false
|
||||||
:return-key-type :go}]]
|
:accessibility-label :enter-contact-code-input
|
||||||
[react/view {:justify-content :center
|
:auto-capitalize :none
|
||||||
:align-items :center}
|
:return-key-type :go}]]
|
||||||
[input-icon state true @entered-nickname blocked?]]]
|
[react/view {:justify-content :center
|
||||||
[react/view {:min-height 30 :justify-content :flex-end :margin-bottom 16}
|
:align-items :center}
|
||||||
[quo/text {:style {:margin-horizontal 16}
|
[input-icon state true @entered-nickname blocked?]]]
|
||||||
:size :small
|
[react/view {:min-height 30 :justify-content :flex-end :margin-bottom 16}
|
||||||
:align :center
|
[quo/text {:style {:margin-horizontal 16}
|
||||||
:color :secondary}
|
:size :small
|
||||||
(cond (= state :error)
|
:align :center
|
||||||
(get-validation-label error)
|
:color :secondary}
|
||||||
(= state :valid)
|
(cond (= state :error)
|
||||||
(str (when ens-name (str ens-name " • "))
|
(get-validation-label error)
|
||||||
(utils/get-shortened-address public-key))
|
(= state :valid)
|
||||||
:else "")]]
|
(str (when ens-name (str ens-name " • "))
|
||||||
[react/text {:style {:margin-horizontal 16 :color colors/gray}}
|
(utils/get-shortened-address public-key))
|
||||||
(i18n/label :t/nickname-description)]
|
:else "")]]
|
||||||
[react/view {:padding 16}
|
[react/text {:style {:margin-horizontal 16 :color colors/gray}}
|
||||||
|
(i18n/label :t/nickname-description)]
|
||||||
[nickname-input entered-nickname]
|
[react/view {:padding 16}
|
||||||
[react/text {:style {:align-self :flex-end :margin-top 16
|
[nickname-input entered-nickname]
|
||||||
:color colors/gray}}
|
[react/text {:style {:align-self :flex-end :margin-top 16
|
||||||
(str (count @entered-nickname) " / 32")]]]))
|
:color colors/gray}}
|
||||||
|
(str (count @entered-nickname) " / 32")]]]))))
|
||||||
|
|
Loading…
Reference in New Issue