From 6d74d0396e937c648bbb96543d803a2d5b77674c Mon Sep 17 00:00:00 2001 From: yqrashawn Date: Thu, 21 Mar 2024 19:19:55 +0800 Subject: [PATCH] fix: show pubkey in add contact input when available (#19187) --- .../chat/home/add_new_contact/views.cljs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/status_im/contexts/chat/home/add_new_contact/views.cljs b/src/status_im/contexts/chat/home/add_new_contact/views.cljs index 8919c7ff999..916b6184de5 100644 --- a/src/status_im/contexts/chat/home/add_new_contact/views.cljs +++ b/src/status_im/contexts/chat/home/add_new_contact/views.cljs @@ -61,9 +61,10 @@ (reset! input-value clipboard-text) (rf/dispatch [:contacts/set-new-identity {:input clipboard-text}])))] - (let [{:keys [scanned]} (rf/sub [:contacts/new-identity]) - empty-input? (and (string/blank? @input-value) - (string/blank? scanned))] + (let [{:keys [scanned] contact-public-key :id} (rf/sub [:contacts/new-identity]) + contact-public-key-or-scanned (or contact-public-key scanned) + empty-input? (and (string/blank? @input-value) + (string/blank? contact-public-key-or-scanned))] [rn/view {:style style/input-and-scan-container} [quo/input {:accessibility-label :enter-contact-code-input @@ -80,15 +81,16 @@ :button (when empty-input? {:on-press paste-on-input :text (i18n/label :t/paste)}) - ;; NOTE: `scanned` has priority over `@input-value`, we clean it when the input is updated - ;; so that it's `nil` and `@input-value` is shown. To fastly clean it, we use - ;; `dispatch-sync`. This call could be avoided if `::qr-scanner/scan-code` were able to + ;; NOTE: `contact-public-key-or-scanned` has priority over `@input-value`, + ;; we clean it when the input is updated so that it's `nil` and + ;; `@input-value`is shown. To fastly clean it, we use `dispatch-sync`. + ;; This call could be avoided if `::qr-scanner/scan-code` were able to ;; receive a callback function, not only a re-frame event as callback. - :value (or scanned @input-value) + :value (or contact-public-key-or-scanned @input-value) :on-change-text (fn [new-text] (reset! input-value new-text) (as-> [:contacts/set-new-identity {:input new-text}] $ - (if (string/blank? scanned) + (if (string/blank? contact-public-key-or-scanned) (debounce/debounce-and-dispatch $ 600) (rf/dispatch-sync $))))}] [rn/view {:style style/scan-button-container}