fix ens name turns into public key while editing message (#14149)

This commit is contained in:
Parvesh Monu 2022-10-14 17:35:36 +05:30 committed by GitHub
parent 509b8bf3e1
commit ac9fb2fe4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 17 deletions

View File

@ -1 +1 @@
1.20.0
1.20.2

View File

@ -185,7 +185,7 @@
[alias name nickname]))
(defn add-searchable-phrases-to-contact
[{:keys [alias name added? blocked? identicon public-key nickname]} community-chat?]
[{:keys [alias name added? blocked? identicon public-key nickname ens-verified]} community-chat?]
(when (and alias
(not (string/blank? alias))
(or name
@ -194,11 +194,12 @@
community-chat?)
(not blocked?))
(add-searchable-phrases
{:alias alias
:name (or (utils/safe-replace name ".stateofus.eth" "") alias)
:identicon identicon
:nickname nickname
:public-key public-key})))
{:alias alias
:name (or (and ens-verified (utils/safe-replace name ".stateofus.eth" "")) alias)
:identicon identicon
:nickname nickname
:ens-verified ens-verified
:public-key public-key})))
(defn mentionable-contacts [contacts]
(reduce

View File

@ -218,16 +218,23 @@
as arguments and returns new fx. Always clear all validation messages."
{:events [:chat.ui.input/set-chat-input-text]}
[{:keys [db] :as cofx} text chat-id]
(let [text-with-mentions (mentions/->input-field text)
contacts (:contacts db)
hydrated-mentions (map (fn [[t mention :as e]]
(if (= t :mention)
[:mention (str "@" (multiaccounts/displayed-name
(or (get contacts mention)
{:public-key mention})))]
e)) text-with-mentions)
info (mentions/->info hydrated-mentions)]
{:set-input-text [chat-id text]
(let [text-with-mentions (mentions/->input-field text)
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)
(let [mention (multiaccounts/displayed-name
(get mentionable-users mention))]
[:mention (if (string/starts-with? mention "@")
mention (str "@" mention))])
e)) text-with-mentions)
info (mentions/->info hydrated-mentions)
new-text (string/join (map second hydrated-mentions))]
{:set-input-text [chat-id new-text]
:db
(-> db
(assoc-in [:chats/cursor chat-id] (:mention-end info))