Skip to content

Commit

Permalink
Fix ENS name display
Browse files Browse the repository at this point in the history
  • Loading branch information
audriu committed Oct 4, 2022
1 parent 99b2809 commit 3e3acd5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
21 changes: 17 additions & 4 deletions src/status_im/chat/models/mentions.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,17 @@
{}
(remove #(= my-public-key %) identities)))

(defn set-ens-verification-statuses
"set status of :ens-verified form all-contacts data"
[mentionable-users all-contacts]
(into {}
(for [[id contact] mentionable-users]
[id (assoc contact
:ens-verified
(-> all-contacts
(get id)
:ens-verified))])))

(defn get-mentionable-users [chat all-contacts current-multiaccount community-members]
(let [{:keys [name preferred-name public-key]} current-multiaccount
{:keys [chat-id users contacts chat-type]} chat
Expand All @@ -238,10 +249,12 @@
(mentionable-contacts-from-identites all-contacts public-key contacts))

(= chat-type constants/one-to-one-chat-type)
(assoc mentionable-users chat-id (get mentionable-contacts chat-id
(-> chat-id
contact.db/public-key->new-contact
contact.db/enrich-contact)))
(let [users
(assoc mentionable-users chat-id (get mentionable-contacts chat-id
(-> chat-id
contact.db/public-key->new-contact
contact.db/enrich-contact)))]
(set-ens-verification-statuses users all-contacts))

(= chat-type constants/community-chat-type)
(mentionable-contacts-from-identites
Expand Down
14 changes: 11 additions & 3 deletions src/status_im/ui/screens/chat/components/input.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,19 @@
[{:keys [db] :as cofx} text chat-id]
(let [text-with-mentions (mentions/->input-field text)
contacts (:contacts db)
all-contacts (:contacts/contacts db)
chat (get-in db [:chats chat-id])
current-multiaccount (:multiaccount db)
mentionable-users (mentions/get-mentionable-users chat all-contacts current-multiaccount nil)
hydrated-mentions (map (fn [[t mention :as e]]
(if (= t :mention)
[:mention (str "@" (multiaccounts/displayed-name
(or (get contacts mention)
{:public-key mention})))]
(let [displayed-name (multiaccounts/displayed-name
(or (get contacts mention)
(get mentionable-users mention)
{:public-key mention}))]
[:mention (if (string/starts-with? displayed-name "@")
displayed-name
(str "@" displayed-name))])
e)) text-with-mentions)
info (mentions/->info hydrated-mentions)]
{:set-input-text [chat-id text]
Expand Down

0 comments on commit 3e3acd5

Please sign in to comment.