From 2c56d70929f86b7a6211643deae36217bf73e59f Mon Sep 17 00:00:00 2001 From: Andrey Shovkoplyas Date: Tue, 14 Jan 2020 15:50:32 +0100 Subject: [PATCH] [#9820] Tap on ENS name in public chats of other users shows own ENS name Signed-off-by: Andrey Shovkoplyas --- .../ui/screens/profile/contact/views.cljs | 8 +++-- .../ui/screens/profile/user/views.cljs | 35 ++++++++----------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/status_im/ui/screens/profile/contact/views.cljs b/src/status_im/ui/screens/profile/contact/views.cljs index dbb28c319f..6c2ef8837b 100644 --- a/src/status_im/ui/screens/profile/contact/views.cljs +++ b/src/status_im/ui/screens/profile/contact/views.cljs @@ -53,13 +53,13 @@ ; :content-height 150} ; contact]) -(defn render-detail [{:keys [alias public-key] :as detail}] +(defn render-detail [{:keys [alias public-key ens-name] :as detail}] [list-item/list-item {:title alias :subtitle (utils/get-shortened-address public-key) :icon [chat-icon/contact-icon-contacts-tab detail] :accessibility-label :profile-public-key - :on-press #(re-frame/dispatch [:show-popover {:view :share-chat-key :address public-key}]) + :on-press #(re-frame/dispatch [:show-popover {:view :share-chat-key :address public-key :ens-name ens-name}]) :accessories [[icons/icon :main-icons/share styles/contact-profile-detail-share-icon]]}]) (defn profile-details-list-view [contact] @@ -132,7 +132,9 @@ :action-separator-style styles/action-separator :icon-opts styles/action-icon-opts}] [react/view styles/contact-profile-details-container - [profile-details contact]] + [profile-details (cond-> contact + (and ens-verified name) + (assoc :ens-name name))]] [block-contact-action contact]] generated-view (large-toolbar/generate-view header-in-toolbar diff --git a/src/status_im/ui/screens/profile/user/views.cljs b/src/status_im/ui/screens/profile/user/views.cljs index 9e1874a0be..f6dd3f3637 100644 --- a/src/status_im/ui/screens/profile/user/views.cljs +++ b/src/status_im/ui/screens/profile/user/views.cljs @@ -1,8 +1,6 @@ (ns status-im.ui.screens.profile.user.views - (:require [clojure.string :as string] - [re-frame.core :as re-frame] + (:require [re-frame.core :as re-frame] [reagent.core :as reagent] - [status-im.ethereum.stateofus :as stateofus] [status-im.i18n :as i18n] [status-im.multiaccounts.core :as multiaccounts] [status-im.ui.components.button :as button] @@ -10,7 +8,6 @@ [status-im.ui.components.common.common :as components.common] [status-im.ui.components.copyable-text :as copyable-text] [status-im.ui.components.large-toolbar.view :as large-toolbar] - [status-im.ui.components.list-item.views :as list-item] [status-im.ui.components.list-selection :as list-selection] [status-im.ui.components.list.views :as list.views] [status-im.ui.components.qr-code-viewer.views :as qr-code-viewer] @@ -20,7 +17,6 @@ [status-im.ui.screens.chat.photos :as photos] [status-im.ui.screens.profile.components.views :as profile.components] [status-im.ui.screens.profile.user.styles :as styles] - [status-im.utils.identicon :as identicon] [status-im.utils.platform :as platform] [status-im.utils.config :as config] [status-im.utils.universal-links.core :as universal-links] @@ -28,28 +24,24 @@ (:require-macros [status-im.utils.views :as views])) (views/defview share-chat-key [] - (views/letsubs [{:keys [address]} [:popover/popover] - width (reagent/atom nil) - {:keys [names preferred-name]} [:ens.main/screen]] - (let [username (stateofus/username preferred-name) - name (or username preferred-name) - link (universal-links/generate-link :user :external address)] + (views/letsubs [{:keys [address ens-name]} [:popover/popover] + width (reagent/atom nil)] + (let [link (universal-links/generate-link :user :external address)] [react/view {:on-layout #(reset! width (-> % .-nativeEvent .-layout .-width))} [react/view {:style {:padding-top 16 :padding-horizontal 16}} (when @width [qr-code-viewer/qr-code-view (- @width 32) address]) - (when (seq names) + (when ens-name [react/view [copyable-text/copyable-text-view - {:label :t/ens-usernames + {:label :t/ens-username :container-style {:margin-top 12 :margin-bottom 4} - :copied-text preferred-name} + :copied-text ens-name} [react/nested-text {:style {:line-height 22 :font-size 15 :font-family "monospace"} :accessibility-label :ens-username} - name - (when username [{:style {:color colors/gray}} (str "." stateofus/domain)])]] + ens-name]] [react/view {:height 1 :margin-top 12 :margin-horizontal -16 :background-color colors/gray-lighter}]]) [copyable-text/copyable-text-view @@ -91,12 +83,15 @@ :text-align :left}} displayed-name]])) -(defn- toolbar-action-items [public-key] +(defn- toolbar-action-items [public-key ens-name] [toolbar/actions [{:icon :main-icons/share :icon-opts {:width 24 :height 24} - :handler #(re-frame/dispatch [:show-popover {:view :share-chat-key :address public-key}])}]]) + :handler #(re-frame/dispatch [:show-popover + {:view :share-chat-key + :address public-key + :ens-name ens-name}])}]]) (defn tribute-to-talk-item [opts] @@ -205,12 +200,12 @@ #(re-frame/dispatch [:multiaccounts.logout.ui/logout-pressed])}]) (defn minimized-toolbar-handler [anim-opacity] - (let [{:keys [public-key] + (let [{:keys [public-key preferred-name] :as multiaccount} @(re-frame/subscribe [:multiaccount])] [large-toolbar/minimized-toolbar-handler (header-in-toolbar multiaccount) nil - (toolbar-action-items public-key) + (toolbar-action-items public-key preferred-name) anim-opacity])) (defn content-with-header [list-ref scroll-y]