[#11160] Hide blocked users from mention suggestions

This commit is contained in:
Roman Volosovskyi 2020-09-17 15:00:46 +03:00
parent 80faac0ca7
commit 1009b71908
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
4 changed files with 36 additions and 26 deletions

View File

@ -94,7 +94,7 @@
:as message}]
(cond-> acc
(and alias (not= alias ""))
(update :users assoc alias {:alias alias
(update :users assoc from {:alias alias
:name (or name alias)
:identicon identicon
:public-key from})

View File

@ -72,7 +72,7 @@
[{:keys [db]} {:keys [chat-id alias name identicon from]}]
(when (and alias (not= alias ""))
{:db (update-in db [:chats chat-id :users] assoc
alias
from
{:alias alias
:name (or name alias)
:identicon identicon

View File

@ -45,7 +45,7 @@
"00000000000000000000000000000000000000000000000000090x0000000000000000000000000000000000000000000000000000000000000000",
:cursor-clock-value 9,
:users
{"alias" {:alias "alias",
{"from" {:alias "alias",
:name "name",
:identicon "identicon",
:public-key "from"}}}}}}
@ -67,7 +67,7 @@
"00000000000000000000000000000000000000000000000000090x0000000000000000000000000000000000000000000000000000000000000000",
:cursor-clock-value 9,
:users
{"alias" {:alias "alias",
{"from" {:alias "alias",
:name "name",
:identicon "identicon",
:public-key "from"}}}}}}

View File

@ -150,6 +150,8 @@
(reg-root-key-sub :contacts/current-contact-identity :contacts/identity)
(reg-root-key-sub :contacts/new-identity :contacts/new-identity)
(reg-root-key-sub :group/selected-contacts :group/selected-contacts)
(reg-root-key-sub :contacts/blocked-set :contacts/blocked)
;;wallet
(reg-root-key-sub :wallet :wallet)
(reg-root-key-sub :prices :prices)
@ -161,6 +163,7 @@
(reg-root-key-sub :wallet/prepare-transaction :wallet/prepare-transaction)
(reg-root-key-sub :wallet-service/manual-setting :wallet-service/manual-setting)
(reg-root-key-sub :wallet-service/state :wallet-service/state)
;;commands
(reg-root-key-sub :commands/select-account :commands/select-account)
@ -856,10 +859,14 @@
:<- [:contacts/contacts]
(fn [contacts]
(reduce
(fn [acc [key {:keys [alias name identicon]}]]
(if (and alias (not= alias ""))
(fn [acc [key {:keys [alias name identicon public-key] :as contact}]]
(println :foo alias (contact.db/blocked? contact))
(if (and alias
(not= alias "")
(not (contact.db/blocked? contact)))
(let [name (utils/safe-replace name ".stateofus.eth" "")]
(assoc acc alias {:alias alias
(assoc acc public-key
{:alias alias
:name (or name alias)
:identicon identicon
:public-key key}))
@ -871,14 +878,17 @@
:chats/mentionable-users
:<- [:chats/current-chat]
:<- [:chats/mentionable-contacts]
:<- [:contacts/blocked-set]
:<- [:multiaccount]
(fn [[{:keys [users]} contacts {:keys [name preferred-name photo-path public-key]}]]
(fn [[{:keys [users]} contacts blocked {:keys [name preferred-name photo-path public-key]}]]
(apply dissoc
(-> users
(merge contacts)
(assoc public-key {:alias name
:name (or preferred-name name)
:identicon photo-path
:public-key public-key}))))
:public-key public-key}))
blocked)))
(re-frame/reg-sub
:chat/mention-suggestions