From e11797aa276e264c18491d8389ad8883ddd68b62 Mon Sep 17 00:00:00 2001 From: Parvesh Monu Date: Tue, 10 May 2022 03:50:14 +0530 Subject: [PATCH 1/2] fix nickname not setted on adding contact --- .../ui/screens/add_new/new_chat/views.cljs | 110 +++++++++--------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/src/status_im/ui/screens/add_new/new_chat/views.cljs b/src/status_im/ui/screens/add_new/new_chat/views.cljs index 808c99ffcab..06d400a76b1 100644 --- a/src/status_im/ui/screens/add_new/new_chat/views.cljs +++ b/src/status_im/ui/screens/add_new/new_chat/views.cljs @@ -254,58 +254,58 @@ :auto-correct false}]) (defn new-contact [] - (let [{:keys [state ens-name public-key error]} @(re-frame/subscribe [:contacts/new-identity]) - entered-nickname (reagent/atom "") - blocked? (and - (utils.db/valid-public-key? (or public-key "")) - @(re-frame/subscribe [:contacts/contact-blocked? public-key]))] - [react/view {:style {:flex 1}} - [topbar/topbar - {:title (i18n/label :t/new-contact) - :modal? true - :right-accessories - [{:icon :qr - :accessibility-label :scan-contact-code-button - :on-press #(re-frame/dispatch [::qr-scanner/scan-code - {:title (i18n/label :t/new-contact) - :handler :contact/qr-code-scanned - :new-contact? true}])}]}] - [react/view {:flex-direction :row - :padding 16} - [react/view {:flex 1 - :padding-right 16} - [quo/text-input - {:on-change-text - #(do - (re-frame/dispatch [:set-in [:contacts/new-identity :state] :searching]) - (debounce/debounce-and-dispatch [:new-chat/set-new-identity %] 600)) - :on-submit-editing - #(when (= state :valid) - (debounce/dispatch-and-chill [:contact.ui/contact-code-submitted true @entered-nickname] 3000)) - :placeholder (i18n/label :t/enter-contact-code) - :show-cancel false - :accessibility-label :enter-contact-code-input - :auto-capitalize :none - :return-key-type :go}]] - [react/view {:justify-content :center - :align-items :center} - [input-icon state true @entered-nickname blocked?]]] - [react/view {:min-height 30 :justify-content :flex-end :margin-bottom 16} - [quo/text {:style {:margin-horizontal 16} - :size :small - :align :center - :color :secondary} - (cond (= state :error) - (get-validation-label error) - (= state :valid) - (str (when ens-name (str ens-name " • ")) - (utils/get-shortened-address public-key)) - :else "")]] - [react/text {:style {:margin-horizontal 16 :color colors/gray}} - (i18n/label :t/nickname-description)] - [react/view {:padding 16} - - [nickname-input entered-nickname] - [react/text {:style {:align-self :flex-end :margin-top 16 - :color colors/gray}} - (str (count @entered-nickname) " / 32")]]])) + (let [entered-nickname (reagent/atom "")] + (fn [] + (let [{:keys [state ens-name public-key error]} @(re-frame/subscribe [:contacts/new-identity]) + blocked? (and + (utils.db/valid-public-key? (or public-key "")) + @(re-frame/subscribe [:contacts/contact-blocked? public-key]))] + [react/view {:style {:flex 1}} + [topbar/topbar + {:title (i18n/label :t/new-contact) + :modal? true + :right-accessories + [{:icon :qr + :accessibility-label :scan-contact-code-button + :on-press #(re-frame/dispatch [::qr-scanner/scan-code + {:title (i18n/label :t/new-contact) + :handler :contact/qr-code-scanned + :new-contact? true}])}]}] + [react/view {:flex-direction :row + :padding 16} + [react/view {:flex 1 + :padding-right 16} + [quo/text-input + {:on-change-text + #(do + (re-frame/dispatch [:set-in [:contacts/new-identity :state] :searching]) + (debounce/debounce-and-dispatch [:new-chat/set-new-identity %] 600)) + :on-submit-editing + #(when (= state :valid) + (debounce/dispatch-and-chill [:contact.ui/contact-code-submitted true @entered-nickname] 3000)) + :placeholder (i18n/label :t/enter-contact-code) + :show-cancel false + :accessibility-label :enter-contact-code-input + :auto-capitalize :none + :return-key-type :go}]] + [react/view {:justify-content :center + :align-items :center} + [input-icon state true @entered-nickname blocked?]]] + [react/view {:min-height 30 :justify-content :flex-end :margin-bottom 16} + [quo/text {:style {:margin-horizontal 16} + :size :small + :align :center + :color :secondary} + (cond (= state :error) + (get-validation-label error) + (= state :valid) + (str (when ens-name (str ens-name " • ")) + (utils/get-shortened-address public-key)) + :else "")]] + [react/text {:style {:margin-horizontal 16 :color colors/gray}} + (i18n/label :t/nickname-description)] + [react/view {:padding 16} + [nickname-input entered-nickname] + [react/text {:style {:align-self :flex-end :margin-top 16 + :color colors/gray}} + (str (count @entered-nickname) " / 32")]]])))) From a1caecced64ae7a65c229e6f6a4f5f44c3160f37 Mon Sep 17 00:00:00 2001 From: Parvesh Monu Date: Tue, 10 May 2022 17:32:04 +0530 Subject: [PATCH 2/2] QA changes --- src/status_im/add_new/core.cljs | 4 ++-- src/status_im/ui/screens/add_new/new_chat/views.cljs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/status_im/add_new/core.cljs b/src/status_im/add_new/core.cljs index e19be04ee97..a24bd0b610c 100644 --- a/src/status_im/add_new/core.cljs +++ b/src/status_im/add_new/core.cljs @@ -68,7 +68,7 @@ (fx/defn 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) (string/starts-with? data "0x")) chat-key (cond @@ -80,7 +80,7 @@ (if-not validation-result (if new-contact? (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 {})) (chat/start-chat cofx chat-key ens-name)) {:utils/show-popup {:title (i18n/label :t/unable-to-read-this-code) diff --git a/src/status_im/ui/screens/add_new/new_chat/views.cljs b/src/status_im/ui/screens/add_new/new_chat/views.cljs index 06d400a76b1..487d8b2fe52 100644 --- a/src/status_im/ui/screens/add_new/new_chat/views.cljs +++ b/src/status_im/ui/screens/add_new/new_chat/views.cljs @@ -270,7 +270,8 @@ :on-press #(re-frame/dispatch [::qr-scanner/scan-code {:title (i18n/label :t/new-contact) :handler :contact/qr-code-scanned - :new-contact? true}])}]}] + :new-contact? true + :nickname @entered-nickname}])}]}] [react/view {:flex-direction :row :padding 16} [react/view {:flex 1